From bbc8ee0bec3f1e8f00d759b065481dbf223db89c Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Wed, 8 Jul 2020 16:22:16 +0100 Subject: [PATCH 1/9] feat(Action): add ability to set initial value of an Action The new InitialValue property allows an Action to have the starting value set in the Unity Editor at edit time. Once the script is started then the InitialValue will be used to set the default state of the Action (but no events will be emitted to denote an action change as technically the state hasn't changed if it is moving to the initial state). This new InitialValue property is only for use in the UnityEditor at Edit time and cannot be changed at runtime nor can it be set via script. If an initial value is required via creation of an Action by script then simply just need to create the Action and call `Receive()` prior to any event listeners being hooked up. This will simply call the `Receive` method and will emit the relevant events, but as no event listeners should have been registered then this won't make any difference. An extra method of `ReceiveInitialValue` has also been added that will allow the `Receive` method to be called with the initial set value. Again, this is only useful for when creating the Action via the Unity Inspector as the InitialValue cannot be changed via script. The `DefaultValue` help text has also been updated to make it more clearer what this property is for as it's not the starting value of the Action, but the value the Action needs to be at to be considered disabled. --- Runtime/Action/Action.cs | 30 +++- Tests/Editor/Action/AllActionTest.cs | 2 + Tests/Editor/Action/BooleanActionTest.cs | 198 +++++++++++++++++++++++ Tests/Editor/Action/FloatActionTest.cs | 196 ++++++++++++++++++++++ 4 files changed, 424 insertions(+), 2 deletions(-) diff --git a/Runtime/Action/Action.cs b/Runtime/Action/Action.cs index 7f9d546a..a811ace2 100644 --- a/Runtime/Action/Action.cs +++ b/Runtime/Action/Action.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; + using Zinnia.Data.Attribute; using Zinnia.Data.Type; /// @@ -65,7 +66,11 @@ protected set /// public abstract void EmitActivationState(); /// - /// Makes the action receive its own default value. + /// Makes the action receive its own initial value to reset it back to when it was first created. + /// + public abstract void ReceiveInitialValue(); + /// + /// Makes the action receive its own default value to set it back to inactive. /// public abstract void ReceiveDefaultValue(); @@ -88,7 +93,13 @@ protected virtual bool CanEmit() public abstract class Action : Action where TSelf : Action where TEvent : UnityEvent, new() { /// - /// The initial value of the action. + /// The initial value upon creation of the component. + /// + [Serialized] + [field: DocumentedByXml, Restricted(RestrictedAttribute.Restrictions.ReadOnlyAtRunTime)] + public TValue InitialValue { get; protected set; } + /// + /// The value that is considered the inactive value. /// [Serialized] [field: DocumentedByXml] @@ -180,6 +191,13 @@ public override void EmitActivationState() } } + /// + [RequiresBehaviourState] + public override void ReceiveInitialValue() + { + Receive(InitialValue); + } + /// [RequiresBehaviourState] public override void ReceiveDefaultValue() @@ -213,6 +231,14 @@ protected virtual void OnEnable() SubscribeToSources(); } + protected virtual void Start() + { + if (!IsValueEqual(InitialValue)) + { + ProcessValue(InitialValue); + } + } + protected virtual void OnDisable() { ProcessValue(DefaultValue); diff --git a/Tests/Editor/Action/AllActionTest.cs b/Tests/Editor/Action/AllActionTest.cs index 0b6697f8..4a083d1c 100644 --- a/Tests/Editor/Action/AllActionTest.cs +++ b/Tests/Editor/Action/AllActionTest.cs @@ -292,6 +292,8 @@ public override void RemoveSource(ZinniaAction.Action action) { } public override void EmitActivationState() { } + public override void ReceiveInitialValue() { } + public override void ReceiveDefaultValue() { } public virtual void SetIsActivated(bool value) diff --git a/Tests/Editor/Action/BooleanActionTest.cs b/Tests/Editor/Action/BooleanActionTest.cs index 9bd4e9b6..d841e8ba 100644 --- a/Tests/Editor/Action/BooleanActionTest.cs +++ b/Tests/Editor/Action/BooleanActionTest.cs @@ -3,8 +3,10 @@ namespace Test.Zinnia.Action { using NUnit.Framework; + using System.Collections; using Test.Zinnia.Utility.Mock; using UnityEngine; + using UnityEngine.TestTools; using Assert = UnityEngine.Assertions.Assert; public class BooleanActionTest @@ -483,6 +485,188 @@ public void ClearSources() Object.DestroyImmediate(sourceObject); } + + [UnityTest] + public IEnumerator DefaultValueFalseAndInitialValueTrue() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + BooleanActionLiveMock liveSubject = containingObject.AddComponent(); + liveSubject.SetInitialValue(true); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + yield return null; + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } + + [UnityTest] + public IEnumerator DefaultValueTrueAndInitialValueTrue() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + BooleanActionLiveMock liveSubject = containingObject.AddComponent(); + + liveSubject.DefaultValue = true; + liveSubject.SetInitialValue(true); + + liveSubject.ForceAwake(); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + yield return null; + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.Receive(false); + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } + + [UnityTest] + public IEnumerator DefaultValueTrueAndInitialValueFalse() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + BooleanActionLiveMock liveSubject = containingObject.AddComponent(); + + liveSubject.DefaultValue = true; + liveSubject.SetInitialValue(false); + + liveSubject.ForceAwake(); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + yield return null; + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.Receive(true); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsTrue(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } + + [UnityTest] + public IEnumerator ResetToInitialValue() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + BooleanActionLiveMock liveSubject = containingObject.AddComponent(); + liveSubject.SetInitialValue(true); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + yield return null; + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.Receive(false); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsTrue(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.ReceiveInitialValue(); + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } } public class BooleanActionMock : BooleanAction @@ -497,4 +681,18 @@ public virtual void SetValue(bool value) Value = value; } } + + public class BooleanActionLiveMock : BooleanAction + { + public virtual void ForceAwake() + { + IsActivated = false; + Awake(); + } + + public virtual void SetInitialValue(bool value) + { + InitialValue = value; + } + } } \ No newline at end of file diff --git a/Tests/Editor/Action/FloatActionTest.cs b/Tests/Editor/Action/FloatActionTest.cs index 890f827b..41d7e088 100644 --- a/Tests/Editor/Action/FloatActionTest.cs +++ b/Tests/Editor/Action/FloatActionTest.cs @@ -3,8 +3,10 @@ namespace Test.Zinnia.Action { using NUnit.Framework; + using System.Collections; using Test.Zinnia.Utility.Mock; using UnityEngine; + using UnityEngine.TestTools; using Assert = UnityEngine.Assertions.Assert; public class FloatActionTest @@ -246,6 +248,186 @@ public void EventsNotEmittedOnDisabledComponent() Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); } + + [UnityTest] + public IEnumerator DefaultValueZeroInitialValueOne() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + FloatActionLiveMock liveSubject = containingObject.AddComponent(); + liveSubject.SetInitialValue(1f); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + yield return null; + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } + + [UnityTest] + public IEnumerator DefaultValueOneInitialValueOne() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + FloatActionLiveMock liveSubject = containingObject.AddComponent(); + liveSubject.DefaultValue = 1f; + liveSubject.SetInitialValue(1f); + + liveSubject.ForceAwake(); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + yield return null; + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.Receive(0f); + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } + + [UnityTest] + public IEnumerator DefaultValueOneInitialValueZero() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + FloatActionLiveMock liveSubject = containingObject.AddComponent(); + liveSubject.DefaultValue = 1f; + liveSubject.SetInitialValue(0f); + + liveSubject.ForceAwake(); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + yield return null; + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.Receive(1f); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsTrue(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } + + [UnityTest] + public IEnumerator ResetToInitialValue() + { + UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); + + FloatActionLiveMock liveSubject = containingObject.AddComponent(); + liveSubject.SetInitialValue(1f); + + liveSubject.Activated.AddListener(activatedListenerMock.Listen); + liveSubject.Deactivated.AddListener(deactivatedListenerMock.Listen); + liveSubject.ValueChanged.AddListener(changedListenerMock.Listen); + liveSubject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsFalse(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + yield return null; + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.Receive(0f); + + Assert.IsFalse(activatedListenerMock.Received); + Assert.IsTrue(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + + activatedListenerMock.Reset(); + deactivatedListenerMock.Reset(); + changedListenerMock.Reset(); + unchangedListenerMock.Reset(); + + liveSubject.ReceiveInitialValue(); + + Assert.IsTrue(activatedListenerMock.Received); + Assert.IsFalse(deactivatedListenerMock.Received); + Assert.IsTrue(changedListenerMock.Received); + Assert.IsFalse(unchangedListenerMock.Received); + } } public class FloatActionMock : FloatAction @@ -260,4 +442,18 @@ public virtual void SetValue(float value) Value = value; } } + + public class FloatActionLiveMock : FloatAction + { + public virtual void ForceAwake() + { + IsActivated = false; + Awake(); + } + + public virtual void SetInitialValue(float value) + { + InitialValue = value; + } + } } \ No newline at end of file From 816dc972979193fd701f1788af28c0753b33f5b8 Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Thu, 9 Jul 2020 13:41:48 +0100 Subject: [PATCH 2/9] feat(Extension): add new data type extensions for common calculations A common calculation is finding a fine grain distance between two points (either Vector2 or Vector3) where the tolerance is also given in the same type as opposed to just a simple `float`. The new Vector2.WithinDistance and Vector3.WithinDistance offer this via the relevant extensions. Another common calculation is converting euler degrees to signed degrees, such as 270' is actually equivalent to -90'. This helps when doing greater than or less than comparisons as a negative rotation of -90' is less than a rotation of 0' whereas 270' as a number would be greater than 0'. The `Vector3.UnsignedEulerToSignedEuler` will convert the current Vector3 of euler angles into a Signed Euler (-180' to 180f) using the new `float.GetSignedDegree` which simply converts a Euler angle into the -180' to 180' range. These are then used to provide new Transform extensions for: * `Transform.SignedEulerAngles` * `Transform.SignedLocalEulerAngles` Which simply return the respective Euler or Local Euler angle for the Transform but in this signed format. --- Runtime/Extension/FloatExtensions.cs | 10 ++++ Runtime/Extension/TransformExtensions.cs | 20 +++++++ Runtime/Extension/Vector2Extensions.cs | 12 ++++ Runtime/Extension/Vector3Extensions.cs | 22 ++++++++ Tests/Editor/Extension/FloatExtensionsTest.cs | 12 ++++ .../Extension/TransformExtensionsTest.cs | 56 +++++++++++++++++++ .../Editor/Extension/Vector2ExtensionsTest.cs | 25 +++++++++ .../Editor/Extension/Vector3ExtensionsTest.cs | 40 +++++++++++++ 8 files changed, 197 insertions(+) diff --git a/Runtime/Extension/FloatExtensions.cs b/Runtime/Extension/FloatExtensions.cs index cb20035c..01f3755a 100644 --- a/Runtime/Extension/FloatExtensions.cs +++ b/Runtime/Extension/FloatExtensions.cs @@ -19,5 +19,15 @@ public static bool ApproxEquals(this float a, float b, float tolerance = float.E float difference = Mathf.Abs(tolerance); return (Mathf.Abs(a - b) <= difference); } + + /// + /// Converts the given degree angle from a full unsigned 0' to 360' range into the signed -180' to 180' equivalent. + /// + /// The unsigned degree to convert. + /// The converted signed degree. + public static float GetSignedDegree(this float degree) + { + return (degree > 180f) ? degree - 360f : degree; + } } } \ No newline at end of file diff --git a/Runtime/Extension/TransformExtensions.cs b/Runtime/Extension/TransformExtensions.cs index 29caaa65..d0fe7efe 100644 --- a/Runtime/Extension/TransformExtensions.cs +++ b/Runtime/Extension/TransformExtensions.cs @@ -22,5 +22,25 @@ public static void SetGlobalScale(this Transform transform, Vector3 globalScale) transform.localScale = Vector3.one; transform.localScale = globalScale.Divide(transform.lossyScale); } + + /// + /// Gets the signed Euler angle of the . + /// + /// The reference to the to get the rotation from. + /// The signed rotation Euler angles. + public static Vector3 SignedEulerAngles(this Transform transform) + { + return transform.eulerAngles.UnsignedEulerToSignedEuler(); + } + + /// + /// Gets the signed local Euler angle of the . + /// + /// The reference to the to get the local rotation from. + /// The local signed rotation Euler angles. + public static Vector3 SignedLocalEulerAngles(this Transform transform) + { + return transform.localEulerAngles.UnsignedEulerToSignedEuler(); + } } } diff --git a/Runtime/Extension/Vector2Extensions.cs b/Runtime/Extension/Vector2Extensions.cs index 9ca4d9ab..d8a632fa 100644 --- a/Runtime/Extension/Vector2Extensions.cs +++ b/Runtime/Extension/Vector2Extensions.cs @@ -39,5 +39,17 @@ public static Vector2 Divide(this Vector2 dividend, Vector2 divisor) { return Vector2.Scale(dividend, Divide(1, divisor)); } + + /// + /// Check whether the source and target points are within a given tolerance distance of each other. + /// + /// The source point. + /// The target point. + /// The tolerance of distance equality. + /// Whether the source and target are within the distance equality tolerance. + public static bool WithinDistance(this Vector2 a, Vector2 b, Vector2 tolerance) + { + return a.x.ApproxEquals(b.x, tolerance.x) && a.y.ApproxEquals(b.y, tolerance.y); + } } } \ No newline at end of file diff --git a/Runtime/Extension/Vector3Extensions.cs b/Runtime/Extension/Vector3Extensions.cs index 051961de..64a75da9 100644 --- a/Runtime/Extension/Vector3Extensions.cs +++ b/Runtime/Extension/Vector3Extensions.cs @@ -39,5 +39,27 @@ public static Vector3 Divide(this Vector3 dividend, Vector3 divisor) { return Vector3.Scale(dividend, Divide(1, divisor)); } + + /// + /// Check whether the source and target points are within a given tolerance distance of each other. + /// + /// The source point. + /// The target point. + /// The tolerance of distance equality. + /// Whether the source and target are within the distance equality tolerance. + public static bool WithinDistance(this Vector3 a, Vector3 b, Vector3 tolerance) + { + return a.x.ApproxEquals(b.x, tolerance.x) && a.y.ApproxEquals(b.y, tolerance.y) && a.z.ApproxEquals(b.z, tolerance.z); + } + + /// + /// Converts an unsigned Euler angle into a signed Euler angle. + /// + /// The unsigned Euler angle to convert. + /// The converted signed Euler angle. + public static Vector3 UnsignedEulerToSignedEuler(this Vector3 eulerAngles) + { + return new Vector3(eulerAngles.x.GetSignedDegree(), eulerAngles.y.GetSignedDegree(), eulerAngles.z.GetSignedDegree()); + } } } \ No newline at end of file diff --git a/Tests/Editor/Extension/FloatExtensionsTest.cs b/Tests/Editor/Extension/FloatExtensionsTest.cs index db58606f..3594f428 100644 --- a/Tests/Editor/Extension/FloatExtensionsTest.cs +++ b/Tests/Editor/Extension/FloatExtensionsTest.cs @@ -36,5 +36,17 @@ public void ApproxEqualsFalse() tolerance = 0.5f; Assert.IsFalse(a.ApproxEquals(b, tolerance)); } + + [Test] + public void GetSignedDegrees() + { + Assert.AreEqual(0f, 0f.GetSignedDegree()); + Assert.AreEqual(90f, 90f.GetSignedDegree()); + Assert.AreEqual(179f, 179f.GetSignedDegree()); + Assert.AreEqual(180f, 180f.GetSignedDegree()); + Assert.AreEqual(-90f, 270f.GetSignedDegree()); + Assert.AreEqual(-179f, 181f.GetSignedDegree()); + Assert.AreEqual(-0f, 360f.GetSignedDegree()); + } } } \ No newline at end of file diff --git a/Tests/Editor/Extension/TransformExtensionsTest.cs b/Tests/Editor/Extension/TransformExtensionsTest.cs index 53b90e8c..db7e7488 100644 --- a/Tests/Editor/Extension/TransformExtensionsTest.cs +++ b/Tests/Editor/Extension/TransformExtensionsTest.cs @@ -27,5 +27,61 @@ public void SetGlobalScaleValid() Object.DestroyImmediate(child.gameObject); Object.DestroyImmediate(parent.gameObject); } + + [Test] + public void SignedEulerAngles() + { + Transform subject = new GameObject().transform; + + Assert.AreEqual(new Vector3(0f, 0f, 0f).ToString(), subject.SignedEulerAngles().ToString()); + + subject.eulerAngles = new Vector3(0f, 90f, 90f); + Assert.AreEqual(new Vector3(0f, 90f, 90f).ToString(), subject.SignedEulerAngles().ToString()); + + subject.eulerAngles = new Vector3(0f, 179f, 90f); + Assert.AreEqual(new Vector3(0f, 179f, 90f).ToString(), subject.SignedEulerAngles().ToString()); + + subject.eulerAngles = new Vector3(0f, 180f, 90f); + Assert.AreEqual(new Vector3(0f, 180f, 90f).ToString(), subject.SignedEulerAngles().ToString()); + + subject.eulerAngles = new Vector3(0f, 181f, 90f); + Assert.AreEqual(new Vector3(0f, -179f, 90f).ToString(), subject.SignedEulerAngles().ToString()); + + subject.eulerAngles = new Vector3(0f, 270f, 90f); + Assert.AreEqual(new Vector3(0f, -90f, 90f).ToString(), subject.SignedEulerAngles().ToString()); + + subject.eulerAngles = new Vector3(0f, 360f, 90f); + Assert.AreEqual(new Vector3(0f, 0f, 90f).ToString(), subject.SignedEulerAngles().ToString()); + + Object.DestroyImmediate(subject.gameObject); + } + + [Test] + public void SignedLocalEulerAngles() + { + Transform subject = new GameObject().transform; + + Assert.AreEqual(new Vector3(0f, 0f, 0f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + subject.localEulerAngles = new Vector3(0f, 90f, 90f); + Assert.AreEqual(new Vector3(0f, 90f, 90f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + subject.localEulerAngles = new Vector3(0f, 179f, 90f); + Assert.AreEqual(new Vector3(0f, 179f, 90f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + subject.localEulerAngles = new Vector3(0f, 180f, 90f); + Assert.AreEqual(new Vector3(0f, 180f, 90f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + subject.localEulerAngles = new Vector3(0f, 181f, 90f); + Assert.AreEqual(new Vector3(0f, -179f, 90f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + subject.localEulerAngles = new Vector3(0f, 270f, 90f); + Assert.AreEqual(new Vector3(0f, -90f, 90f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + subject.localEulerAngles = new Vector3(0f, 360f, 90f); + Assert.AreEqual(new Vector3(0f, 0f, 90f).ToString(), subject.SignedLocalEulerAngles().ToString()); + + Object.DestroyImmediate(subject.gameObject); + } } } \ No newline at end of file diff --git a/Tests/Editor/Extension/Vector2ExtensionsTest.cs b/Tests/Editor/Extension/Vector2ExtensionsTest.cs index 6401f35e..44249b89 100644 --- a/Tests/Editor/Extension/Vector2ExtensionsTest.cs +++ b/Tests/Editor/Extension/Vector2ExtensionsTest.cs @@ -49,5 +49,30 @@ public void DivideByVector() Vector2 b = Vector2.one * 2f; Assert.AreEqual(Vector2.one * 5f, a.Divide(b)); } + + [Test] + public void WithinDistance() + { + Vector2 a = new Vector2(0f, 0f); + Vector2 b = new Vector2(0f, 0f); + Vector2 tolerance = new Vector2(0.2f, 0.3f); + + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector2(0.1f, 0.1f); + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector2(0.2f, 0.2f); + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector2(0.2f, 0.3f); + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector2(0.3f, 0.3f); + Assert.IsFalse(a.WithinDistance(b, tolerance)); + + b = new Vector2(0.3f, 0.4f); + Assert.IsFalse(a.WithinDistance(b, tolerance)); + } } } \ No newline at end of file diff --git a/Tests/Editor/Extension/Vector3ExtensionsTest.cs b/Tests/Editor/Extension/Vector3ExtensionsTest.cs index 56db3dbb..58e52cf9 100644 --- a/Tests/Editor/Extension/Vector3ExtensionsTest.cs +++ b/Tests/Editor/Extension/Vector3ExtensionsTest.cs @@ -49,5 +49,45 @@ public void DivideByVector() Vector3 b = Vector3.one * 2f; Assert.AreEqual(Vector3.one * 5f, a.Divide(b)); } + + [Test] + public void WithinDistance() + { + Vector3 a = new Vector3(0f, 0f, 0f); + Vector3 b = new Vector3(0f, 0f, 0f); + Vector3 tolerance = new Vector3(0.2f, 0.3f, 0.4f); + + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector3(0.1f, 0.1f, 0.1f); + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector3(0.2f, 0.2f, 0.2f); + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector3(0.2f, 0.3f, 0.3f); + Assert.IsTrue(a.WithinDistance(b, tolerance)); + + b = new Vector3(0.3f, 0.3f, 0.3f); + Assert.IsFalse(a.WithinDistance(b, tolerance)); + + b = new Vector3(0.3f, 0.4f, 0.4f); + Assert.IsFalse(a.WithinDistance(b, tolerance)); + + b = new Vector3(0.3f, 0.4f, 0.5f); + Assert.IsFalse(a.WithinDistance(b, tolerance)); + } + + [Test] + public void UnsignedEulerToSignedEuler() + { + Assert.AreEqual(new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f).UnsignedEulerToSignedEuler()); + Assert.AreEqual(new Vector3(90f, 90f, 90f), new Vector3(90f, 90f, 90f).UnsignedEulerToSignedEuler()); + Assert.AreEqual(new Vector3(179f, 179f, 179f), new Vector3(179f, 179f, 179f).UnsignedEulerToSignedEuler()); + Assert.AreEqual(new Vector3(180f, 180f, 180f), new Vector3(180f, 180f, 180f).UnsignedEulerToSignedEuler()); + Assert.AreEqual(new Vector3(-179f, -179f, -179f), new Vector3(181f, 181f, 181f).UnsignedEulerToSignedEuler()); + Assert.AreEqual(new Vector3(-90f, -90f, -90f), new Vector3(270f, 270f, 270f).UnsignedEulerToSignedEuler()); + Assert.AreEqual(new Vector3(0f, 0f, 0f), new Vector3(360f, 360f, 360f).UnsignedEulerToSignedEuler()); + } } } \ No newline at end of file From 8538d3f435738ec8e5254dc3b18a4efd81978e4a Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Thu, 9 Jul 2020 13:50:15 +0100 Subject: [PATCH 3/9] feat(Tracking): add divergable property modifier types A new Property Modifier type known as a Divergable Property Modifier has been added that allows a property modifier to know when the target has become diverged from the source in whatever property it is tracking. Only certain types of modifier can actually ever cause a divergence, such as the RigidbodyVelocity and RigidbodyAngularVelocity because they can make it so the target is not keeping exactly up to date with the source and become diverged somewhat. So now both RigidbodyVelocity and RigidbodyAngularVelocity have become extensions of the DivergablePropertyModifier and now emit events when the source/target diverge and converge again. It is also possible to turn off this divergence tracking and it is turned off by default as it adds an additional overhead, which should not be automatically implemented unless the overhead is warranted for the benefits of using the functionality. --- .../Property/DivergablePropertyModifier.cs | 144 ++++++++++++++++++ .../DivergablePropertyModifier.cs.meta | 11 ++ .../Property/Position/RigidbodyVelocity.cs | 30 +++- .../Modifier/Property/PropertyModifier.cs | 20 ++- .../Rotation/RigidbodyAngularVelocity.cs | 32 +++- .../Position/RigidbodyVelocityTest.cs | 103 +++++++++++++ .../Position/TransformPositionTest.cs | 2 + .../Rotation/RigidbodyAngularVelocityTest.cs | 105 ++++++++++++- .../Rotation/TransformRotationTest.cs | 2 + .../Property/Scale/TransformScaleTest.cs | 2 + 10 files changed, 433 insertions(+), 18 deletions(-) create mode 100644 Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs create mode 100644 Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs.meta diff --git a/Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs b/Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs new file mode 100644 index 00000000..5e4be6d7 --- /dev/null +++ b/Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs @@ -0,0 +1,144 @@ +namespace Zinnia.Tracking.Follow.Modifier.Property +{ + using Malimbe.PropertySerializationAttribute; + using Malimbe.XmlDocumentationAttribute; + using System.Collections.Generic; + using UnityEngine; + using Zinnia.Extension; + + /// + /// Modifies a property by a mechanism that can cause the target to diverge from the source. + /// + public abstract class DivergablePropertyModifier : PropertyModifier + { + #region Divergence Events + /// + /// Emitted when the target is back within the threshold distance of the source after being diverged. + /// + [Header("Divergence Events"), DocumentedByXml] + public ObjectFollower.FollowEvent Converged = new ObjectFollower.FollowEvent(); + /// + /// Emitted when the target is no longer within the threshold distance of the source. + /// + [DocumentedByXml] + public ObjectFollower.FollowEvent Diverged = new ObjectFollower.FollowEvent(); + #endregion + + #region Divergence Settings + /// + /// Determines if to track whether the source diverges from the target. Tracking divergence adds additional overhead. + /// + [Serialized] + [field: Header("Divergence Settings"), DocumentedByXml] + public bool TrackDivergence { get; set; } + /// + /// The distance the target has to be away from the source to be considered diverged. + /// + [Serialized] + [field: DocumentedByXml] + public Vector3 DivergenceThreshold { get; set; } = Vector3.one * 0.1f; + #endregion + + /// + /// A collection of currently diverged states. + /// + protected HashSet divergedStates = new HashSet(); + + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetDivergenceThresholdX(float value) + { + DivergenceThreshold = new Vector3(value, DivergenceThreshold.y, DivergenceThreshold.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetDivergenceThresholdY(float value) + { + DivergenceThreshold = new Vector3(DivergenceThreshold.x, value, DivergenceThreshold.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetDivergenceThresholdZ(float value) + { + DivergenceThreshold = new Vector3(DivergenceThreshold.x, DivergenceThreshold.y, value); + } + + /// + /// Whether the given source and target are diverged. + /// + /// The source to check against. + /// The target to check with. + /// Whether a divergence is occurring. + public virtual bool AreDiverged(GameObject source, GameObject target) + { + return divergedStates.Contains(GenerateIdentifier(source, target)); + } + + /// + /// Gets the two points from the source and target to check divergence against. + /// + /// The source to check against. + /// The target to check with. + /// Any offset applied to the target. + /// The first point to use. + /// The second point to use. + protected abstract void GetCheckPoints(GameObject source, GameObject target, GameObject offset, out Vector3 a, out Vector3 b); + + /// + protected override void DoModify(GameObject source, GameObject target, GameObject offset = null) + { + if (TrackDivergence) + { + CheckDivergence(source, target, offset); + } + } + + /// + /// Generates the unique key for the divergence check. + /// + /// The source of the divergence check. + /// The target of the divergence check. + /// The unique identifier. + protected virtual string GenerateIdentifier(GameObject source, GameObject target) + { + return source.GetInstanceID() + "-" + target.GetInstanceID(); + } + + /// + /// Checks to see if the target has diverged from the source within the . + /// + /// The source to check against. + /// The target to check with. + /// Any offset applied to the target. + protected virtual void CheckDivergence(GameObject source, GameObject target, GameObject offset) + { + string divergeKey = GenerateIdentifier(source, target); + bool areDiverged = AreDiverged(source, target); + GetCheckPoints(source, target, offset, out Vector3 sourcePoint, out Vector3 targetPoint); + + if (!sourcePoint.WithinDistance(targetPoint, DivergenceThreshold)) + { + if (areDiverged) + { + return; + } + + divergedStates.Add(divergeKey); + Diverged?.Invoke(eventData.Set(source, target, offset)); + } + else if (areDiverged) + { + divergedStates.Remove(divergeKey); + Converged?.Invoke(eventData.Set(source, target, offset)); + } + } + } +} \ No newline at end of file diff --git a/Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs.meta b/Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs.meta new file mode 100644 index 00000000..ac4f87c0 --- /dev/null +++ b/Runtime/Tracking/Follow/Modifier/Property/DivergablePropertyModifier.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: faee86694d6f4e147b9bb9e92c5c79a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocity.cs b/Runtime/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocity.cs index d2363776..4fae66f4 100644 --- a/Runtime/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocity.cs +++ b/Runtime/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocity.cs @@ -6,15 +6,16 @@ using Zinnia.Extension; /// - /// Updates the rigidbody velocity by moving towards a given source. + /// Updates the velocity by moving towards a given source. /// - public class RigidbodyVelocity : PropertyModifier + public class RigidbodyVelocity : DivergablePropertyModifier { + #region Velocity Settings /// /// The maximum squared magnitude of velocity that can be applied to the source. /// [Serialized] - [field: DocumentedByXml] + [field: Header("Velocity Settings"), DocumentedByXml] public float VelocityLimit { get; set; } = float.PositiveInfinity; /// /// The maximum difference in distance to the tracked position. @@ -22,9 +23,10 @@ public class RigidbodyVelocity : PropertyModifier [Serialized] [field: DocumentedByXml] public float MaxDistanceDelta { get; set; } = 10f; + #endregion /// - /// A cached version of the target rigidbody. + /// A cached version of the target . /// protected Rigidbody cachedTargetRigidbody; /// @@ -51,6 +53,26 @@ protected override void DoModify(GameObject source, GameObject target, GameObjec { cachedTargetRigidbody.velocity = calculatedVelocity; } + + base.DoModify(source, target, offset); + } + + /// + /// Gets the source and target positions to check divergence against. + /// + /// The source to check against. + /// The target to check with. + /// Any offset applied to the target. + /// The source position. + /// The target position. + protected override void GetCheckPoints(GameObject source, GameObject target, GameObject offset, out Vector3 a, out Vector3 b) + { + a = source.transform.position; + b = target.transform.position; + if (offset != null) + { + b += offset.transform.localPosition; + } } } } \ No newline at end of file diff --git a/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs b/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs index b74f4abb..0c15427a 100644 --- a/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs +++ b/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs @@ -11,23 +11,27 @@ /// public abstract class PropertyModifier : MonoBehaviour { - /// - /// Determines whether the offset will be applied on the modification. - /// - [Serialized] - [field: DocumentedByXml] - public bool ApplyOffset { get; set; } = true; - + #region Modifier Events /// /// Emitted before the property is modified. /// - [DocumentedByXml] + [Header("Modifier Events"), DocumentedByXml] public ObjectFollower.FollowEvent Premodified = new ObjectFollower.FollowEvent(); /// /// Emitted after the property is modified. /// [DocumentedByXml] public ObjectFollower.FollowEvent Modified = new ObjectFollower.FollowEvent(); + #endregion + + #region Modifier Settings + /// + /// Determines whether the offset will be applied on the modification. + /// + [Serialized] + [field: Header("Modifier Settings"), DocumentedByXml] + public bool ApplyOffset { get; set; } = true; + #endregion /// /// The event data to emit before and after the property has been modified. diff --git a/Runtime/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocity.cs b/Runtime/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocity.cs index e98f2ced..782c03ef 100644 --- a/Runtime/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocity.cs +++ b/Runtime/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocity.cs @@ -6,15 +6,16 @@ using Zinnia.Extension; /// - /// Updates the rigidbody angular velocity by rotating towards a given source. + /// Updates the angular velocity by rotating towards a given source. /// - public class RigidbodyAngularVelocity : PropertyModifier + public class RigidbodyAngularVelocity : DivergablePropertyModifier { + #region Velocity Settings /// /// The maximum squared magnitude of angular velocity that can be applied to the source . /// [Serialized] - [field: DocumentedByXml] + [field: Header("Velocity Settings"), DocumentedByXml] public float AngularVelocityLimit { get; set; } = float.PositiveInfinity; /// /// The maximum difference in distance to the tracked position. @@ -22,9 +23,10 @@ public class RigidbodyAngularVelocity : PropertyModifier [Serialized] [field: DocumentedByXml] public float MaxDistanceDelta { get; set; } = 10f; + #endregion /// - /// A cached version of the target rigidbody. + /// A cached version of the target . /// protected Rigidbody cachedTargetRigidbody; /// @@ -46,7 +48,7 @@ protected override void DoModify(GameObject source, GameObject target, GameObjec Quaternion rotationDelta = source.transform.rotation * Quaternion.Inverse(offset != null ? offset.transform.rotation : target.transform.rotation); rotationDelta.ToAngleAxis(out float angle, out Vector3 axis); - angle = (angle > 180f) ? angle - 360f : angle; + angle = angle.GetSignedDegree(); if (!angle.ApproxEquals(0)) { @@ -57,6 +59,26 @@ protected override void DoModify(GameObject source, GameObject target, GameObjec cachedTargetRigidbody.angularVelocity = calculatedAngularVelocity; } } + + base.DoModify(source, target, offset); + } + + /// + /// Gets the source and target Euler rotations to check divergence against. + /// + /// The source to check against. + /// The target to check with. + /// Any offset applied to the target. + /// The source position. + /// The target position. + protected override void GetCheckPoints(GameObject source, GameObject target, GameObject offset, out Vector3 a, out Vector3 b) + { + a = source.transform.SignedEulerAngles(); + b = target.transform.SignedEulerAngles(); + if (offset != null) + { + b = (offset.transform.localRotation * target.transform.rotation).eulerAngles.UnsignedEulerToSignedEuler(); + } } } } \ No newline at end of file diff --git a/Tests/Editor/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocityTest.cs b/Tests/Editor/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocityTest.cs index e6f7d829..0d681101 100644 --- a/Tests/Editor/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocityTest.cs +++ b/Tests/Editor/Tracking/Follow/Modifier/Property/Position/RigidbodyVelocityTest.cs @@ -3,8 +3,11 @@ namespace Test.Zinnia.Tracking.Follow.Modifier.Property.Position { using NUnit.Framework; + using System.Collections; using Test.Zinnia.Utility; + using Test.Zinnia.Utility.Mock; using UnityEngine; + using UnityEngine.TestTools; using Assert = UnityEngine.Assertions.Assert; public class RigidbodyVelocityTest @@ -56,6 +59,53 @@ public void Modify() Object.DestroyImmediate(target); } + [UnityTest] + public IEnumerator ModifyAndDiverge() + { + subject.TrackDivergence = true; + GameObject source = new GameObject(); + GameObject target = subject.gameObject; + + UnityEventListenerMock convergedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock divergedListenerMock = new UnityEventListenerMock(); + subject.Converged.AddListener(convergedListenerMock.Listen); + subject.Diverged.AddListener(divergedListenerMock.Listen); + + source.transform.position = Vector3.zero; + target.transform.position = Vector3.zero; + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsFalse(subject.AreDiverged(source, target)); + + source.transform.position = Vector3.one * 10f; + + subject.Modify(source, target); + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsTrue(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsTrue(subject.AreDiverged(source, target)); + + while (subject.AreDiverged(source, target)) + { + subject.Modify(source, target); + yield return null; + } + + Assert.IsTrue(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + Assert.IsFalse(subject.AreDiverged(source, target)); + + Object.DestroyImmediate(source); + Object.DestroyImmediate(target); + } + [Test] public void ModifyWithOffset() { @@ -63,6 +113,8 @@ public void ModifyWithOffset() GameObject target = subject.gameObject; GameObject offset = new GameObject(); + offset.transform.SetParent(target.transform); + source.transform.position = Vector3.one; target.transform.position = Vector3.zero; offset.transform.position = Vector3.one * 2f; @@ -83,6 +135,57 @@ public void ModifyWithOffset() Object.DestroyImmediate(offset); } + [UnityTest] + public IEnumerator ModifyWithOffsetAndDiverge() + { + subject.TrackDivergence = true; + GameObject source = new GameObject(); + GameObject target = subject.gameObject; + GameObject offset = new GameObject(); + + UnityEventListenerMock convergedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock divergedListenerMock = new UnityEventListenerMock(); + subject.Converged.AddListener(convergedListenerMock.Listen); + subject.Diverged.AddListener(divergedListenerMock.Listen); + + offset.transform.SetParent(target.transform); + + source.transform.position = Vector3.zero; + target.transform.position = Vector3.zero; + offset.transform.position = Vector3.one * 2f; + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsFalse(subject.AreDiverged(source, target)); + + source.transform.position = Vector3.one * 10f; + + subject.Modify(source, target, offset); + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsTrue(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsTrue(subject.AreDiverged(source, target)); + + while (subject.AreDiverged(source, target)) + { + subject.Modify(source, target); + yield return null; + } + + Assert.IsTrue(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + Assert.IsFalse(subject.AreDiverged(source, target)); + + Object.DestroyImmediate(source); + Object.DestroyImmediate(target); + } + [Test] public void ModifyWithOffsetIgnored() { diff --git a/Tests/Editor/Tracking/Follow/Modifier/Property/Position/TransformPositionTest.cs b/Tests/Editor/Tracking/Follow/Modifier/Property/Position/TransformPositionTest.cs index ba170227..5777b019 100644 --- a/Tests/Editor/Tracking/Follow/Modifier/Property/Position/TransformPositionTest.cs +++ b/Tests/Editor/Tracking/Follow/Modifier/Property/Position/TransformPositionTest.cs @@ -50,6 +50,8 @@ public void ModifyWithOffset() GameObject target = new GameObject(); GameObject offset = new GameObject(); + offset.transform.SetParent(target.transform); + source.transform.position = Vector3.one * 2f; target.transform.position = Vector3.zero; offset.transform.position = Vector3.one * 0.5f; diff --git a/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocityTest.cs b/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocityTest.cs index 11ecbb07..e9073310 100644 --- a/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocityTest.cs +++ b/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/RigidbodyAngularVelocityTest.cs @@ -3,8 +3,11 @@ namespace Test.Zinnia.Tracking.Follow.Modifier.Property.Rotation { using NUnit.Framework; + using System.Collections; using Test.Zinnia.Utility; + using Test.Zinnia.Utility.Mock; using UnityEngine; + using UnityEngine.TestTools; using Assert = UnityEngine.Assertions.Assert; public class RigidbodyAngularVelocityTest @@ -56,6 +59,53 @@ public void Modify() Object.DestroyImmediate(target); } + [UnityTest] + public IEnumerator ModifyAndDiverge() + { + subject.TrackDivergence = true; + GameObject source = new GameObject(); + GameObject target = subject.gameObject; + + UnityEventListenerMock convergedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock divergedListenerMock = new UnityEventListenerMock(); + subject.Converged.AddListener(convergedListenerMock.Listen); + subject.Diverged.AddListener(divergedListenerMock.Listen); + + source.transform.rotation = Quaternion.identity; + target.transform.rotation = Quaternion.identity; + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsFalse(subject.AreDiverged(source, target)); + + source.transform.rotation = Quaternion.Euler(90f, 0f, 0f); + + subject.Modify(source, target); + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsTrue(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsTrue(subject.AreDiverged(source, target)); + + while (subject.AreDiverged(source, target)) + { + subject.Modify(source, target); + yield return null; + } + + Assert.IsTrue(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + Assert.IsFalse(subject.AreDiverged(source, target)); + + Object.DestroyImmediate(source); + Object.DestroyImmediate(target); + } + [Test] public void ModifyWithOffset() { @@ -63,9 +113,11 @@ public void ModifyWithOffset() GameObject target = subject.gameObject; GameObject offset = new GameObject(); + offset.transform.SetParent(target.transform); + source.transform.rotation = Quaternion.Euler(90f, 0f, 0f); target.transform.rotation = Quaternion.identity; - offset.transform.position = Vector3.one * 2f; + offset.transform.rotation = Quaternion.Euler(45f, 0f, 0f); Vector3 expectedVelocity = Vector3.zero; Vector3 expectedAngularVelocity = Vector3.right * 10f; @@ -83,6 +135,57 @@ public void ModifyWithOffset() Object.DestroyImmediate(offset); } + [UnityTest] + public IEnumerator ModifyWithOffsetAndDiverge() + { + subject.TrackDivergence = true; + GameObject source = new GameObject(); + GameObject target = subject.gameObject; + GameObject offset = new GameObject(); + + UnityEventListenerMock convergedListenerMock = new UnityEventListenerMock(); + UnityEventListenerMock divergedListenerMock = new UnityEventListenerMock(); + subject.Converged.AddListener(convergedListenerMock.Listen); + subject.Diverged.AddListener(divergedListenerMock.Listen); + + offset.transform.SetParent(target.transform); + + source.transform.rotation = Quaternion.identity; + target.transform.rotation = Quaternion.identity; + offset.transform.rotation = Quaternion.Euler(45f, 0f, 0f); + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsFalse(subject.AreDiverged(source, target)); + + source.transform.rotation = Quaternion.Euler(90f, 0f, 0f); + + subject.Modify(source, target, offset); + + Assert.IsFalse(convergedListenerMock.Received); + Assert.IsTrue(divergedListenerMock.Received); + convergedListenerMock.Reset(); + divergedListenerMock.Reset(); + + Assert.IsTrue(subject.AreDiverged(source, target)); + + while (subject.AreDiverged(source, target)) + { + subject.Modify(source, target); + yield return null; + } + + Assert.IsTrue(convergedListenerMock.Received); + Assert.IsFalse(divergedListenerMock.Received); + Assert.IsFalse(subject.AreDiverged(source, target)); + + Object.DestroyImmediate(source); + Object.DestroyImmediate(target); + } + [Test] public void ModifyWithOffsetIgnored() { diff --git a/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/TransformRotationTest.cs b/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/TransformRotationTest.cs index c5158394..7156b88a 100644 --- a/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/TransformRotationTest.cs +++ b/Tests/Editor/Tracking/Follow/Modifier/Property/Rotation/TransformRotationTest.cs @@ -52,6 +52,8 @@ public void ModifyWithOffset() GameObject target = new GameObject(); GameObject offset = new GameObject(); + offset.transform.SetParent(target.transform); + Quaternion sourceRotation = new Quaternion(1f, 0f, 0f, 0f); source.transform.rotation = sourceRotation; target.transform.rotation = Quaternion.identity; diff --git a/Tests/Editor/Tracking/Follow/Modifier/Property/Scale/TransformScaleTest.cs b/Tests/Editor/Tracking/Follow/Modifier/Property/Scale/TransformScaleTest.cs index fb016a8a..7dbcb431 100644 --- a/Tests/Editor/Tracking/Follow/Modifier/Property/Scale/TransformScaleTest.cs +++ b/Tests/Editor/Tracking/Follow/Modifier/Property/Scale/TransformScaleTest.cs @@ -49,6 +49,8 @@ public void ModifyWithOffset() GameObject target = new GameObject(); GameObject offset = new GameObject(); + offset.transform.SetParent(target.transform); + source.transform.localScale = Vector3.one * 4f; target.transform.localScale = Vector3.one; offset.transform.localScale = Vector3.one * 2f; From 0da6d51802e0ef5975df5620770ea437e516621b Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Thu, 9 Jul 2020 14:31:12 +0100 Subject: [PATCH 4/9] feat(Tracking): add proxy emitter for ObjectFollower.EventData The ObjectFollower.EventData can now be proxied via the new ObjectFollowerEventProxyEmitter and this data can also now be used as an input to the PropertyModifier `Modify` method as this makes it easy to chain Property Modifiers together to have one modifier use its data to call another Property Modifier. --- Runtime/Tracking/Follow/Event.meta | 8 +++ Runtime/Tracking/Follow/Event/Proxy.meta | 8 +++ .../Proxy/ObjectFollowerEventProxyEmitter.cs | 60 +++++++++++++++++++ .../ObjectFollowerEventProxyEmitter.cs.meta | 11 ++++ .../Modifier/Property/PropertyModifier.cs | 10 ++++ 5 files changed, 97 insertions(+) create mode 100644 Runtime/Tracking/Follow/Event.meta create mode 100644 Runtime/Tracking/Follow/Event/Proxy.meta create mode 100644 Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs create mode 100644 Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs.meta diff --git a/Runtime/Tracking/Follow/Event.meta b/Runtime/Tracking/Follow/Event.meta new file mode 100644 index 00000000..7062f16c --- /dev/null +++ b/Runtime/Tracking/Follow/Event.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8afa20b4df7445a4f80580a8dafb8680 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Tracking/Follow/Event/Proxy.meta b/Runtime/Tracking/Follow/Event/Proxy.meta new file mode 100644 index 00000000..6ad09058 --- /dev/null +++ b/Runtime/Tracking/Follow/Event/Proxy.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de04a6f868c35d94c817e6aa31b2f1d0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs b/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs new file mode 100644 index 00000000..2679538c --- /dev/null +++ b/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs @@ -0,0 +1,60 @@ +namespace Zinnia.Tracking.Follow.Event.Proxy +{ + using Malimbe.PropertySerializationAttribute; + using Malimbe.XmlDocumentationAttribute; + using System; + using UnityEngine; + using UnityEngine.Events; + using Zinnia.Event.Proxy; + + public class ObjectFollowerEventProxyEmitter : RestrictableSingleEventProxyEmitter + { + /// + /// Defines the event with the specified state. + /// + [Serializable] + public class UnityEvent : UnityEvent { } + + /// + /// The types of that can be used for the rule source. + /// + public enum RuleSourceType + { + /// + /// Use the for the rule. + /// + Source, + /// + /// Use the for the rule. + /// + Target, + /// + /// Use the for the rule. + /// + TargetOffset + } + + /// + /// The source to apply to the . + /// + [Serialized] + [field: DocumentedByXml] + public RuleSourceType RuleSource { get; set; } + + /// + protected override object GetTargetToCheck() + { + switch (RuleSource) + { + case RuleSourceType.Source: + return Payload.EventSource.gameObject; + case RuleSourceType.Target: + return Payload.EventTarget.gameObject; + case RuleSourceType.TargetOffset: + return Payload.EventTargetOffset.gameObject; + default: + return null; + } + } + } +} \ No newline at end of file diff --git a/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs.meta b/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs.meta new file mode 100644 index 00000000..c794dd6a --- /dev/null +++ b/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 26131e3d3e722ab4e989bde8c4455e69 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs b/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs index 0c15427a..007d3d9b 100644 --- a/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs +++ b/Runtime/Tracking/Follow/Modifier/Property/PropertyModifier.cs @@ -38,6 +38,16 @@ public abstract class PropertyModifier : MonoBehaviour /// protected readonly ObjectFollower.EventData eventData = new ObjectFollower.EventData(); + /// + /// Attempts to modify the target. + /// + /// Event data that contains the required modifier properties. + [RequiresBehaviourState] + public virtual void Modifiy(ObjectFollower.EventData data) + { + Modify(data.EventSource, data.EventTarget, data.EventTargetOffset); + } + /// /// Attempts modify the target. /// From fea537b56976f1d9f2aa9944c116d2d3fc07d9a4 Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Thu, 9 Jul 2020 19:47:58 +0100 Subject: [PATCH 5/9] refactor(guidelines): apply coding guidelines to empty classes The coding guidelines state that empty classes should have the brackets on the same line as such: `class { }` and not ``` class { } ``` This has now been applied to the relevant offending files. --- Runtime/Action/BooleanAction.cs | 4 +--- Runtime/Action/FloatAction.cs | 4 +--- Runtime/Action/Vector2Action.cs | 4 +--- Runtime/Action/Vector3Action.cs | 4 +--- .../Collection/GameObjectsAssociationObservableList.cs | 4 +--- Runtime/Data/Attribute/UnityFlagsAttribute.cs | 4 +--- .../Collection/Counter/GameObjectObservableCounter.cs | 4 +--- Runtime/Data/Collection/GameObjectRelations.cs | 4 +--- Runtime/Data/Collection/List/BehaviourObservableList.cs | 4 +--- Runtime/Data/Collection/List/CameraObservableList.cs | 4 +--- Runtime/Data/Collection/List/FloatObservableList.cs | 4 +--- Runtime/Data/Collection/List/GameObjectObservableList.cs | 4 +--- .../Collection/List/GameObjectRelationObservableList.cs | 4 +--- .../List/SerializableTypeBehaviourObservableList.cs | 4 +--- .../List/SerializableTypeComponentObservableList.cs | 4 +--- Runtime/Data/Collection/List/StringObservableList.cs | 4 +--- Runtime/Data/Collection/List/UnityObjectObservableList.cs | 4 +--- Runtime/Data/Collection/List/Vector2ObservableList.cs | 4 +--- Runtime/Data/Collection/List/Vector3ObservableList.cs | 4 +--- .../Data/Collection/Stack/GameObjectObservableStack.cs | 4 +--- Runtime/Data/Operation/Cache/FloatCache.cs | 4 +--- Runtime/Data/Operation/Cache/GameObjectCache.cs | 4 +--- Runtime/Data/Operation/Cache/IntCache.cs | 4 +--- Runtime/Data/Operation/Cache/StringCache.cs | 4 +--- Runtime/Data/Operation/Cache/Vector2Cache.cs | 4 +--- Runtime/Data/Operation/Cache/Vector3Cache.cs | 4 +--- .../Operation/Extraction/ComponentGameObjectExtractor.cs | 4 +--- .../Operation/Extraction/ComponentRigidbodyExtractor.cs | 4 +--- .../Operation/Extraction/RaycastHitColliderExtractor.cs | 4 +--- .../Operation/Extraction/RaycastHitDistanceExtractor.cs | 4 +--- .../Operation/Extraction/RaycastHitNormalExtractor.cs | 4 +--- .../Data/Operation/Extraction/RaycastHitPointExtractor.cs | 4 +--- .../Operation/Extraction/RaycastHitRigidbodyExtractor.cs | 4 +--- .../Extraction/RaycastHitTextureCoordExtractor.cs | 4 +--- .../Operation/Extraction/RaycastHitTransformExtractor.cs | 4 +--- .../Extraction/SurfaceDataCollisionPointExtractor.cs | 4 +--- .../Data/Operation/Extraction/TimeComponentExtractor.cs | 4 +--- .../Extraction/TransformDataGameObjectExtractor.cs | 4 +--- .../Extraction/TransformVector3PropertyExtractor.cs | 4 +--- Runtime/Data/Operation/GameObjectCloner.cs | 4 +--- Runtime/Data/Type/HeapAllocationFreeReadOnlyList.cs | 4 +--- .../Data/Type/Transformation/Aggregation/FloatAdder.cs | 4 +--- .../Type/Transformation/Aggregation/FloatMultiplier.cs | 4 +--- .../Type/Transformation/Aggregation/Vector2Multiplier.cs | 4 +--- .../Type/Transformation/Aggregation/Vector3Multiplier.cs | 4 +--- .../Type/Transformation/Aggregation/Vector3Subtractor.cs | 4 +--- .../Data/Type/Transformation/Conversion/BooleanToFloat.cs | 6 ++---- .../Data/Type/Transformation/Conversion/FloatToBoolean.cs | 4 +--- .../Transformation/Conversion/FloatToNormalizedFloat.cs | 4 +--- .../Data/Type/Transformation/Conversion/FloatToVector2.cs | 4 +--- .../Data/Type/Transformation/Conversion/FloatToVector3.cs | 4 +--- .../Transformation/Conversion/NormalizedFloatToFloat.cs | 4 +--- .../Data/Type/Transformation/Conversion/Vector2ToAngle.cs | 4 +--- .../Type/Transformation/Conversion/Vector2ToVector3.cs | 4 +--- .../Type/Transformation/Conversion/Vector3ToVector2.cs | 4 +--- .../Data/Type/Transformation/FloatRangeValueRemapper.cs | 4 +--- .../Data/Type/Transformation/Vector3MagnitudeSetter.cs | 4 +--- Runtime/Data/Type/Transformation/Vector3Restrictor.cs | 4 +--- Runtime/Event/Proxy/FloatEventProxyEmitter.cs | 4 +--- Runtime/Event/Proxy/GameObjectEventProxyEmitter.cs | 4 +--- Runtime/Event/Proxy/SurfaceDataProxyEmitter.cs | 4 +--- Runtime/Event/Proxy/TransformDataProxyEmitter.cs | 4 +--- Runtime/Event/Proxy/Vector2EventProxyEmitter.cs | 4 +--- Runtime/Event/Proxy/Vector3EventProxyEmitter.cs | 4 +--- Runtime/Haptics/Collection/HapticProcessObservableList.cs | 4 +--- Runtime/Pointer/ObjectPointer.cs | 8 ++------ .../Moment/Collection/MomentProcessObservableList.cs | 4 +--- Runtime/Process/ProcessContainer.cs | 4 +--- Runtime/Rule/Collection/RuleContainerObservableList.cs | 4 +--- .../Rule/Collection/RulesMatcherElementObservableList.cs | 4 +--- Runtime/Rule/RuleContainer.cs | 4 +--- .../LinkedAliasAssociationCollectionObservableList.cs | 4 +--- .../Operation/Extraction/PlayAreaDimensionsExtractor.cs | 4 +--- .../Tracking/Collision/Active/ActiveCollisionConsumer.cs | 4 +--- .../Tracking/Collision/Active/ActiveCollisionPublisher.cs | 4 +--- .../Collision/Active/ActiveCollisionsContainer.cs | 4 +--- .../Tracking/Collision/Active/CollisionPointContainer.cs | 4 +--- .../Proxy/ActiveCollisionConsumerEventProxyEmitter.cs | 4 +--- .../Proxy/ActiveCollisionsContainerEventProxyEmitter.cs | 4 +--- .../Operation/Extraction/NotifierContainerExtractor.cs | 4 +--- .../Operation/Extraction/NotifierTargetExtractor.cs | 4 +--- .../Operation/Extraction/PublisherContainerExtractor.cs | 4 +--- .../Event/Proxy/CollisionNotifierEventProxyEmitter.cs | 4 +--- Runtime/Tracking/Follow/ObjectDistanceComparator.cs | 4 +--- Runtime/Tracking/Follow/ObjectFollower.cs | 4 +--- .../ObjectDistanceComparatorEventDataExtractor.cs | 8 ++------ .../TransformPropertyApplierEventDataExtractor.cs | 4 +--- Runtime/Tracking/Modification/TransformPropertyApplier.cs | 4 +--- Runtime/Tracking/Query/ObscuranceQuery.cs | 4 +--- .../Velocity/Collection/VelocityTrackerObservableList.cs | 4 +--- Runtime/Tracking/Velocity/VelocityEmitter.cs | 8 ++------ Runtime/Utility/CountdownTimer.cs | 4 +--- Runtime/Utility/InterfaceContainer.cs | 4 +--- Runtime/Visual/CameraColorOverlay.cs | 4 +--- .../Data/Operation/Extraction/GameObjectExtractorTest.cs | 4 +--- Tests/Editor/Rule/AnyBehaviourEnabledRuleTest.cs | 4 +--- Tests/Editor/Rule/AnyComponentTypeRuleTest.cs | 4 +--- Tests/Utility/Stub/RuleStub.cs | 4 +--- 98 files changed, 102 insertions(+), 304 deletions(-) diff --git a/Runtime/Action/BooleanAction.cs b/Runtime/Action/BooleanAction.cs index b43c584c..00c4e998 100644 --- a/Runtime/Action/BooleanAction.cs +++ b/Runtime/Action/BooleanAction.cs @@ -12,8 +12,6 @@ public class BooleanAction : Action state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Action/FloatAction.cs b/Runtime/Action/FloatAction.cs index de2f3e5c..16d18817 100644 --- a/Runtime/Action/FloatAction.cs +++ b/Runtime/Action/FloatAction.cs @@ -16,9 +16,7 @@ public class FloatAction : Action /// Defines the event with the state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The tolerance of equality between two values. diff --git a/Runtime/Action/Vector2Action.cs b/Runtime/Action/Vector2Action.cs index b8c16515..3c017618 100644 --- a/Runtime/Action/Vector2Action.cs +++ b/Runtime/Action/Vector2Action.cs @@ -17,9 +17,7 @@ public class Vector2Action : Action state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The tolerance of equality between two values. diff --git a/Runtime/Action/Vector3Action.cs b/Runtime/Action/Vector3Action.cs index 71f22461..467f95b8 100644 --- a/Runtime/Action/Vector3Action.cs +++ b/Runtime/Action/Vector3Action.cs @@ -17,9 +17,7 @@ public class Vector3Action : Action state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The tolerance of equality between two values. diff --git a/Runtime/Association/Collection/GameObjectsAssociationObservableList.cs b/Runtime/Association/Collection/GameObjectsAssociationObservableList.cs index d3bc698b..1bea17b2 100644 --- a/Runtime/Association/Collection/GameObjectsAssociationObservableList.cs +++ b/Runtime/Association/Collection/GameObjectsAssociationObservableList.cs @@ -14,8 +14,6 @@ public class GameObjectsAssociationObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Attribute/UnityFlagsAttribute.cs b/Runtime/Data/Attribute/UnityFlagsAttribute.cs index 6a191add..a5f56576 100644 --- a/Runtime/Data/Attribute/UnityFlagsAttribute.cs +++ b/Runtime/Data/Attribute/UnityFlagsAttribute.cs @@ -5,7 +5,5 @@ /// /// Defines the [UnityFlags] attribute. /// - public class UnityFlagsAttribute : PropertyAttribute - { - } + public class UnityFlagsAttribute : PropertyAttribute { } } \ No newline at end of file diff --git a/Runtime/Data/Collection/Counter/GameObjectObservableCounter.cs b/Runtime/Data/Collection/Counter/GameObjectObservableCounter.cs index 3e02d909..71957dcd 100644 --- a/Runtime/Data/Collection/Counter/GameObjectObservableCounter.cs +++ b/Runtime/Data/Collection/Counter/GameObjectObservableCounter.cs @@ -14,8 +14,6 @@ public class GameObjectObservableCounter : ObservableCounter. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/GameObjectRelations.cs b/Runtime/Data/Collection/GameObjectRelations.cs index 6abc8dbc..e2edaf91 100644 --- a/Runtime/Data/Collection/GameObjectRelations.cs +++ b/Runtime/Data/Collection/GameObjectRelations.cs @@ -17,9 +17,7 @@ public class GameObjectRelations : MonoBehaviour /// Defines the event for the output . /// [Serializable] - public class GameObjectUnityEvent : UnityEvent - { - } + public class GameObjectUnityEvent : UnityEvent { } /// /// The collection of relations. diff --git a/Runtime/Data/Collection/List/BehaviourObservableList.cs b/Runtime/Data/Collection/List/BehaviourObservableList.cs index 1bb88967..75f02e6d 100644 --- a/Runtime/Data/Collection/List/BehaviourObservableList.cs +++ b/Runtime/Data/Collection/List/BehaviourObservableList.cs @@ -14,8 +14,6 @@ public class BehaviourObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } diff --git a/Runtime/Data/Collection/List/CameraObservableList.cs b/Runtime/Data/Collection/List/CameraObservableList.cs index 4a83610e..dc4bd1d4 100644 --- a/Runtime/Data/Collection/List/CameraObservableList.cs +++ b/Runtime/Data/Collection/List/CameraObservableList.cs @@ -14,8 +14,6 @@ public class CameraObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/List/FloatObservableList.cs b/Runtime/Data/Collection/List/FloatObservableList.cs index ea151d33..477bf470 100644 --- a/Runtime/Data/Collection/List/FloatObservableList.cs +++ b/Runtime/Data/Collection/List/FloatObservableList.cs @@ -13,8 +13,6 @@ public class FloatObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } diff --git a/Runtime/Data/Collection/List/GameObjectObservableList.cs b/Runtime/Data/Collection/List/GameObjectObservableList.cs index fac5039e..ba87f17e 100644 --- a/Runtime/Data/Collection/List/GameObjectObservableList.cs +++ b/Runtime/Data/Collection/List/GameObjectObservableList.cs @@ -14,8 +14,6 @@ public class GameObjectObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/List/GameObjectRelationObservableList.cs b/Runtime/Data/Collection/List/GameObjectRelationObservableList.cs index 51fb1c97..fa9d265f 100644 --- a/Runtime/Data/Collection/List/GameObjectRelationObservableList.cs +++ b/Runtime/Data/Collection/List/GameObjectRelationObservableList.cs @@ -37,8 +37,6 @@ public class Relation /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/List/SerializableTypeBehaviourObservableList.cs b/Runtime/Data/Collection/List/SerializableTypeBehaviourObservableList.cs index e13fd794..43e788a0 100644 --- a/Runtime/Data/Collection/List/SerializableTypeBehaviourObservableList.cs +++ b/Runtime/Data/Collection/List/SerializableTypeBehaviourObservableList.cs @@ -25,8 +25,6 @@ public class SerializableTypeBehaviourObservableList : ObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/List/SerializableTypeComponentObservableList.cs b/Runtime/Data/Collection/List/SerializableTypeComponentObservableList.cs index 4ce785da..f67043d4 100644 --- a/Runtime/Data/Collection/List/SerializableTypeComponentObservableList.cs +++ b/Runtime/Data/Collection/List/SerializableTypeComponentObservableList.cs @@ -25,8 +25,6 @@ public class SerializableTypeComponentObservableList : ObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/List/StringObservableList.cs b/Runtime/Data/Collection/List/StringObservableList.cs index d159e5c8..6cdf13e3 100644 --- a/Runtime/Data/Collection/List/StringObservableList.cs +++ b/Runtime/Data/Collection/List/StringObservableList.cs @@ -13,8 +13,6 @@ public class StringObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } diff --git a/Runtime/Data/Collection/List/UnityObjectObservableList.cs b/Runtime/Data/Collection/List/UnityObjectObservableList.cs index b354fecf..681e8b67 100644 --- a/Runtime/Data/Collection/List/UnityObjectObservableList.cs +++ b/Runtime/Data/Collection/List/UnityObjectObservableList.cs @@ -14,8 +14,6 @@ public class UnityObjectObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Collection/List/Vector2ObservableList.cs b/Runtime/Data/Collection/List/Vector2ObservableList.cs index b73c4e71..a974ea54 100644 --- a/Runtime/Data/Collection/List/Vector2ObservableList.cs +++ b/Runtime/Data/Collection/List/Vector2ObservableList.cs @@ -14,8 +14,6 @@ public class Vector2ObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } diff --git a/Runtime/Data/Collection/List/Vector3ObservableList.cs b/Runtime/Data/Collection/List/Vector3ObservableList.cs index a4701ce3..a12245d1 100644 --- a/Runtime/Data/Collection/List/Vector3ObservableList.cs +++ b/Runtime/Data/Collection/List/Vector3ObservableList.cs @@ -14,8 +14,6 @@ public class Vector3ObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } diff --git a/Runtime/Data/Collection/Stack/GameObjectObservableStack.cs b/Runtime/Data/Collection/Stack/GameObjectObservableStack.cs index f291db27..0e7dc7c9 100644 --- a/Runtime/Data/Collection/Stack/GameObjectObservableStack.cs +++ b/Runtime/Data/Collection/Stack/GameObjectObservableStack.cs @@ -19,9 +19,7 @@ public class GameObjectElementEvents : ObservableStackElementEvents. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } } \ No newline at end of file diff --git a/Runtime/Data/Operation/Cache/FloatCache.cs b/Runtime/Data/Operation/Cache/FloatCache.cs index 6331ce40..b5870405 100644 --- a/Runtime/Data/Operation/Cache/FloatCache.cs +++ b/Runtime/Data/Operation/Cache/FloatCache.cs @@ -13,9 +13,7 @@ public class FloatCache : ValueCache /// Defines the event with the specified . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The tolerance to consider the current value and the cached value equal. diff --git a/Runtime/Data/Operation/Cache/GameObjectCache.cs b/Runtime/Data/Operation/Cache/GameObjectCache.cs index 7413da6d..28502aae 100644 --- a/Runtime/Data/Operation/Cache/GameObjectCache.cs +++ b/Runtime/Data/Operation/Cache/GameObjectCache.cs @@ -11,8 +11,6 @@ public class GameObjectCache : ValueCache. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Operation/Cache/IntCache.cs b/Runtime/Data/Operation/Cache/IntCache.cs index 9c0a9190..ab4985f3 100644 --- a/Runtime/Data/Operation/Cache/IntCache.cs +++ b/Runtime/Data/Operation/Cache/IntCache.cs @@ -10,8 +10,6 @@ public class IntCache : ValueCache /// Defines the event with the specified . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Operation/Cache/StringCache.cs b/Runtime/Data/Operation/Cache/StringCache.cs index 6c77365e..6272788f 100644 --- a/Runtime/Data/Operation/Cache/StringCache.cs +++ b/Runtime/Data/Operation/Cache/StringCache.cs @@ -10,8 +10,6 @@ public class StringCache : ValueCache /// Defines the event with the specified . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Data/Operation/Cache/Vector2Cache.cs b/Runtime/Data/Operation/Cache/Vector2Cache.cs index 56078416..f99e45c0 100644 --- a/Runtime/Data/Operation/Cache/Vector2Cache.cs +++ b/Runtime/Data/Operation/Cache/Vector2Cache.cs @@ -14,9 +14,7 @@ public class Vector2Cache : ValueCache /// Defines the event with the specified . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The tolerance to consider the current value and the cached value equal. diff --git a/Runtime/Data/Operation/Cache/Vector3Cache.cs b/Runtime/Data/Operation/Cache/Vector3Cache.cs index 0ae0c519..e0c46301 100644 --- a/Runtime/Data/Operation/Cache/Vector3Cache.cs +++ b/Runtime/Data/Operation/Cache/Vector3Cache.cs @@ -14,9 +14,7 @@ public class Vector3Cache : ValueCache /// Defines the event with the specified . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The tolerance to consider the current value and the cached value equal. diff --git a/Runtime/Data/Operation/Extraction/ComponentGameObjectExtractor.cs b/Runtime/Data/Operation/Extraction/ComponentGameObjectExtractor.cs index 2d2c6ea4..341891c0 100644 --- a/Runtime/Data/Operation/Extraction/ComponentGameObjectExtractor.cs +++ b/Runtime/Data/Operation/Extraction/ComponentGameObjectExtractor.cs @@ -13,9 +13,7 @@ public class ComponentGameObjectExtractor : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override GameObject ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/ComponentRigidbodyExtractor.cs b/Runtime/Data/Operation/Extraction/ComponentRigidbodyExtractor.cs index aaa30d6b..6910c369 100644 --- a/Runtime/Data/Operation/Extraction/ComponentRigidbodyExtractor.cs +++ b/Runtime/Data/Operation/Extraction/ComponentRigidbodyExtractor.cs @@ -14,9 +14,7 @@ public class ComponentRigidbodyExtractor : ComponentExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Rigidbody ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitColliderExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitColliderExtractor.cs index 72dcfe75..c34f3119 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitColliderExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitColliderExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitColliderExtractor : ValueExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Collider ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitDistanceExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitDistanceExtractor.cs index b0200573..fd1d885d 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitDistanceExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitDistanceExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitDistanceExtractor : FloatExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override float? ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitNormalExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitNormalExtractor.cs index dfe42d0b..d3a45dcf 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitNormalExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitNormalExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitNormalExtractor : Vector3Extractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Vector3? ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitPointExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitPointExtractor.cs index eeca54e3..8e58701f 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitPointExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitPointExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitPointExtractor : Vector3Extractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Vector3? ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitRigidbodyExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitRigidbodyExtractor.cs index f7647dea..0169ddd8 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitRigidbodyExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitRigidbodyExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitRigidbodyExtractor : ValueExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Rigidbody ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitTextureCoordExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitTextureCoordExtractor.cs index d60b1323..88544f15 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitTextureCoordExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitTextureCoordExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitTextureCoordExtractor : Vector2Extractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Vector2? ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/RaycastHitTransformExtractor.cs b/Runtime/Data/Operation/Extraction/RaycastHitTransformExtractor.cs index 1602bdf6..30d3f1d9 100644 --- a/Runtime/Data/Operation/Extraction/RaycastHitTransformExtractor.cs +++ b/Runtime/Data/Operation/Extraction/RaycastHitTransformExtractor.cs @@ -13,9 +13,7 @@ public class RaycastHitTransformExtractor : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override GameObject ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/SurfaceDataCollisionPointExtractor.cs b/Runtime/Data/Operation/Extraction/SurfaceDataCollisionPointExtractor.cs index 942e096b..590345c7 100644 --- a/Runtime/Data/Operation/Extraction/SurfaceDataCollisionPointExtractor.cs +++ b/Runtime/Data/Operation/Extraction/SurfaceDataCollisionPointExtractor.cs @@ -15,9 +15,7 @@ public class SurfaceDataCollisionPointExtractor : Vector3Extractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Vector3? ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs b/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs index cc3820a9..4b319a02 100644 --- a/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs +++ b/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs @@ -13,9 +13,7 @@ public class TimeComponentExtractor : FloatExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The components of diff --git a/Runtime/Data/Operation/Extraction/TransformDataGameObjectExtractor.cs b/Runtime/Data/Operation/Extraction/TransformDataGameObjectExtractor.cs index f17a5cf0..96dc67a2 100644 --- a/Runtime/Data/Operation/Extraction/TransformDataGameObjectExtractor.cs +++ b/Runtime/Data/Operation/Extraction/TransformDataGameObjectExtractor.cs @@ -14,9 +14,7 @@ public class TransformDataGameObjectExtractor : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override GameObject ExtractValue() diff --git a/Runtime/Data/Operation/Extraction/TransformVector3PropertyExtractor.cs b/Runtime/Data/Operation/Extraction/TransformVector3PropertyExtractor.cs index 702476ff..eb85bbd5 100644 --- a/Runtime/Data/Operation/Extraction/TransformVector3PropertyExtractor.cs +++ b/Runtime/Data/Operation/Extraction/TransformVector3PropertyExtractor.cs @@ -15,9 +15,7 @@ public abstract class TransformVector3PropertyExtractor : Vector3Extractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Determines whether to extract the local property or the world property. diff --git a/Runtime/Data/Operation/GameObjectCloner.cs b/Runtime/Data/Operation/GameObjectCloner.cs index b91fe343..5171620c 100644 --- a/Runtime/Data/Operation/GameObjectCloner.cs +++ b/Runtime/Data/Operation/GameObjectCloner.cs @@ -17,9 +17,7 @@ public class GameObjectCloner : MonoBehaviour /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The object to clone. diff --git a/Runtime/Data/Type/HeapAllocationFreeReadOnlyList.cs b/Runtime/Data/Type/HeapAllocationFreeReadOnlyList.cs index 30569c07..33799351 100644 --- a/Runtime/Data/Type/HeapAllocationFreeReadOnlyList.cs +++ b/Runtime/Data/Type/HeapAllocationFreeReadOnlyList.cs @@ -53,9 +53,7 @@ public Enumerator(IList list, int start, int count) } /// - public void Dispose() - { - } + public void Dispose() { } /// public bool MoveNext() diff --git a/Runtime/Data/Type/Transformation/Aggregation/FloatAdder.cs b/Runtime/Data/Type/Transformation/Aggregation/FloatAdder.cs index 26506d5e..e65d90d2 100644 --- a/Runtime/Data/Type/Transformation/Aggregation/FloatAdder.cs +++ b/Runtime/Data/Type/Transformation/Aggregation/FloatAdder.cs @@ -16,9 +16,7 @@ public class FloatAdder : CollectionAggregator value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override float ProcessCollection() diff --git a/Runtime/Data/Type/Transformation/Aggregation/FloatMultiplier.cs b/Runtime/Data/Type/Transformation/Aggregation/FloatMultiplier.cs index ccbc88cb..4f5b7bea 100644 --- a/Runtime/Data/Type/Transformation/Aggregation/FloatMultiplier.cs +++ b/Runtime/Data/Type/Transformation/Aggregation/FloatMultiplier.cs @@ -16,9 +16,7 @@ public class FloatMultiplier : CollectionAggregator value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override float ProcessCollection() diff --git a/Runtime/Data/Type/Transformation/Aggregation/Vector2Multiplier.cs b/Runtime/Data/Type/Transformation/Aggregation/Vector2Multiplier.cs index 3d57eeff..7cb32da6 100644 --- a/Runtime/Data/Type/Transformation/Aggregation/Vector2Multiplier.cs +++ b/Runtime/Data/Type/Transformation/Aggregation/Vector2Multiplier.cs @@ -17,9 +17,7 @@ public class Vector2Multiplier : CollectionAggregator value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Sets the x value of the element. diff --git a/Runtime/Data/Type/Transformation/Aggregation/Vector3Multiplier.cs b/Runtime/Data/Type/Transformation/Aggregation/Vector3Multiplier.cs index 706c0ba9..18cc5c0d 100644 --- a/Runtime/Data/Type/Transformation/Aggregation/Vector3Multiplier.cs +++ b/Runtime/Data/Type/Transformation/Aggregation/Vector3Multiplier.cs @@ -17,9 +17,7 @@ public class Vector3Multiplier : CollectionAggregator value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Sets the x value of the element. diff --git a/Runtime/Data/Type/Transformation/Aggregation/Vector3Subtractor.cs b/Runtime/Data/Type/Transformation/Aggregation/Vector3Subtractor.cs index b3c591aa..6f64f6b6 100644 --- a/Runtime/Data/Type/Transformation/Aggregation/Vector3Subtractor.cs +++ b/Runtime/Data/Type/Transformation/Aggregation/Vector3Subtractor.cs @@ -17,9 +17,7 @@ public class Vector3Subtractor : CollectionAggregator value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Vector3 ProcessCollection() diff --git a/Runtime/Data/Type/Transformation/Conversion/BooleanToFloat.cs b/Runtime/Data/Type/Transformation/Conversion/BooleanToFloat.cs index 0b0e7677..cc9d8f1b 100644 --- a/Runtime/Data/Type/Transformation/Conversion/BooleanToFloat.cs +++ b/Runtime/Data/Type/Transformation/Conversion/BooleanToFloat.cs @@ -16,12 +16,10 @@ public class BooleanToFloat : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// - /// Transforms the given input bool to the float equivalent value. + /// Transforms the given input to the float equivalent value. /// /// The value to transform. /// The transformed value. diff --git a/Runtime/Data/Type/Transformation/Conversion/FloatToBoolean.cs b/Runtime/Data/Type/Transformation/Conversion/FloatToBoolean.cs index 0bddf2e2..2dc907d4 100644 --- a/Runtime/Data/Type/Transformation/Conversion/FloatToBoolean.cs +++ b/Runtime/Data/Type/Transformation/Conversion/FloatToBoolean.cs @@ -20,9 +20,7 @@ public class FloatToBoolean : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The bounds in which the float must be to be considered a positive boolean. diff --git a/Runtime/Data/Type/Transformation/Conversion/FloatToNormalizedFloat.cs b/Runtime/Data/Type/Transformation/Conversion/FloatToNormalizedFloat.cs index ae03b43b..a42b3aa9 100644 --- a/Runtime/Data/Type/Transformation/Conversion/FloatToNormalizedFloat.cs +++ b/Runtime/Data/Type/Transformation/Conversion/FloatToNormalizedFloat.cs @@ -20,9 +20,7 @@ public class FloatToNormalizedFloat : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The range in which to consider the minimum and maximum value for normalizing. diff --git a/Runtime/Data/Type/Transformation/Conversion/FloatToVector2.cs b/Runtime/Data/Type/Transformation/Conversion/FloatToVector2.cs index 32c2695a..a95ac222 100644 --- a/Runtime/Data/Type/Transformation/Conversion/FloatToVector2.cs +++ b/Runtime/Data/Type/Transformation/Conversion/FloatToVector2.cs @@ -18,9 +18,7 @@ public class FloatToVector2 : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// A float to use as the current x value of the Vector2. diff --git a/Runtime/Data/Type/Transformation/Conversion/FloatToVector3.cs b/Runtime/Data/Type/Transformation/Conversion/FloatToVector3.cs index 4b18def9..480639aa 100644 --- a/Runtime/Data/Type/Transformation/Conversion/FloatToVector3.cs +++ b/Runtime/Data/Type/Transformation/Conversion/FloatToVector3.cs @@ -18,9 +18,7 @@ public class FloatToVector3 : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// A float to use as the current x value of the Vector3. diff --git a/Runtime/Data/Type/Transformation/Conversion/NormalizedFloatToFloat.cs b/Runtime/Data/Type/Transformation/Conversion/NormalizedFloatToFloat.cs index ad040869..add13a8c 100644 --- a/Runtime/Data/Type/Transformation/Conversion/NormalizedFloatToFloat.cs +++ b/Runtime/Data/Type/Transformation/Conversion/NormalizedFloatToFloat.cs @@ -20,9 +20,7 @@ public class NormalizedFloatToFloat : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The range in which to consider the minimum and maximum value for de-normalizing. diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs b/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs index d5a6796b..5c3a4136 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs @@ -25,9 +25,7 @@ public class Vector2ToAngle : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The unit to calculate the angle in. diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs b/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs index 6375c7d8..0a6c2a64 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs @@ -20,9 +20,7 @@ public class Vector2ToVector3 : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The mapping of coordinates to the coordinates. diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs b/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs index 99518c62..02d75d54 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs @@ -20,9 +20,7 @@ public class Vector3ToVector2 : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The mapping of coordinates to the coordinates. diff --git a/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs b/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs index f94ad098..06da8762 100644 --- a/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs +++ b/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs @@ -22,9 +22,7 @@ public class FloatRangeValueRemapper : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The range of the value from. diff --git a/Runtime/Data/Type/Transformation/Vector3MagnitudeSetter.cs b/Runtime/Data/Type/Transformation/Vector3MagnitudeSetter.cs index 35322fb4..4977eea4 100644 --- a/Runtime/Data/Type/Transformation/Vector3MagnitudeSetter.cs +++ b/Runtime/Data/Type/Transformation/Vector3MagnitudeSetter.cs @@ -15,9 +15,7 @@ public class Vector3MagnitudeSetter : Transformer with the changed magnitude. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The magnitude to use when transforming values. diff --git a/Runtime/Data/Type/Transformation/Vector3Restrictor.cs b/Runtime/Data/Type/Transformation/Vector3Restrictor.cs index 6041f2dc..f1962fa4 100644 --- a/Runtime/Data/Type/Transformation/Vector3Restrictor.cs +++ b/Runtime/Data/Type/Transformation/Vector3Restrictor.cs @@ -19,9 +19,7 @@ public class Vector3Restrictor : Transformer value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The minimum and maximum values that the x coordinate can be. diff --git a/Runtime/Event/Proxy/FloatEventProxyEmitter.cs b/Runtime/Event/Proxy/FloatEventProxyEmitter.cs index 2981ed86..faf000b1 100644 --- a/Runtime/Event/Proxy/FloatEventProxyEmitter.cs +++ b/Runtime/Event/Proxy/FloatEventProxyEmitter.cs @@ -12,8 +12,6 @@ public class FloatEventProxyEmitter : SingleEventProxyEmitter [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Event/Proxy/GameObjectEventProxyEmitter.cs b/Runtime/Event/Proxy/GameObjectEventProxyEmitter.cs index 3b7c2d73..be768f4e 100644 --- a/Runtime/Event/Proxy/GameObjectEventProxyEmitter.cs +++ b/Runtime/Event/Proxy/GameObjectEventProxyEmitter.cs @@ -13,9 +13,7 @@ public class GameObjectEventProxyEmitter : RestrictableSingleEventProxyEmitter [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override object GetTargetToCheck() diff --git a/Runtime/Event/Proxy/SurfaceDataProxyEmitter.cs b/Runtime/Event/Proxy/SurfaceDataProxyEmitter.cs index 5badb89e..25c564d2 100644 --- a/Runtime/Event/Proxy/SurfaceDataProxyEmitter.cs +++ b/Runtime/Event/Proxy/SurfaceDataProxyEmitter.cs @@ -13,8 +13,6 @@ public class SurfaceDataProxyEmitter : SingleEventProxyEmitter [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Event/Proxy/TransformDataProxyEmitter.cs b/Runtime/Event/Proxy/TransformDataProxyEmitter.cs index 2a70da24..498e98dd 100644 --- a/Runtime/Event/Proxy/TransformDataProxyEmitter.cs +++ b/Runtime/Event/Proxy/TransformDataProxyEmitter.cs @@ -13,8 +13,6 @@ public class TransformDataProxyEmitter : SingleEventProxyEmitter [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Event/Proxy/Vector2EventProxyEmitter.cs b/Runtime/Event/Proxy/Vector2EventProxyEmitter.cs index dd179d9b..a91dd77d 100644 --- a/Runtime/Event/Proxy/Vector2EventProxyEmitter.cs +++ b/Runtime/Event/Proxy/Vector2EventProxyEmitter.cs @@ -13,8 +13,6 @@ public class Vector2EventProxyEmitter : SingleEventProxyEmitter [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Event/Proxy/Vector3EventProxyEmitter.cs b/Runtime/Event/Proxy/Vector3EventProxyEmitter.cs index 811278d6..132612e0 100644 --- a/Runtime/Event/Proxy/Vector3EventProxyEmitter.cs +++ b/Runtime/Event/Proxy/Vector3EventProxyEmitter.cs @@ -13,8 +13,6 @@ public class Vector3EventProxyEmitter : SingleEventProxyEmitter [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Haptics/Collection/HapticProcessObservableList.cs b/Runtime/Haptics/Collection/HapticProcessObservableList.cs index 41fc9eb4..8c093fb5 100644 --- a/Runtime/Haptics/Collection/HapticProcessObservableList.cs +++ b/Runtime/Haptics/Collection/HapticProcessObservableList.cs @@ -14,8 +14,6 @@ public class HapticProcessObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Pointer/ObjectPointer.cs b/Runtime/Pointer/ObjectPointer.cs index a77da4c7..648ec218 100644 --- a/Runtime/Pointer/ObjectPointer.cs +++ b/Runtime/Pointer/ObjectPointer.cs @@ -75,17 +75,13 @@ public override void Clear() /// /// The data is in case the isn't hitting any target. [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Defines the event with the state. /// [Serializable] - public class PointsRendererUnityEvent : UnityEvent - { - } + public class PointsRendererUnityEvent : UnityEvent { } /// /// Represents the origin, i.e. the first rendered point. diff --git a/Runtime/Process/Moment/Collection/MomentProcessObservableList.cs b/Runtime/Process/Moment/Collection/MomentProcessObservableList.cs index 78bc74ac..9321d63f 100644 --- a/Runtime/Process/Moment/Collection/MomentProcessObservableList.cs +++ b/Runtime/Process/Moment/Collection/MomentProcessObservableList.cs @@ -14,8 +14,6 @@ public class MomentProcessObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Process/ProcessContainer.cs b/Runtime/Process/ProcessContainer.cs index a87dfba2..6ee94109 100644 --- a/Runtime/Process/ProcessContainer.cs +++ b/Runtime/Process/ProcessContainer.cs @@ -7,7 +7,5 @@ /// A proxy class used to make a interface appear in the Unity Inspector. /// [Serializable] - public sealed class ProcessContainer : InterfaceContainer - { - } + public sealed class ProcessContainer : InterfaceContainer { } } \ No newline at end of file diff --git a/Runtime/Rule/Collection/RuleContainerObservableList.cs b/Runtime/Rule/Collection/RuleContainerObservableList.cs index 877fdcbd..f084b9ef 100644 --- a/Runtime/Rule/Collection/RuleContainerObservableList.cs +++ b/Runtime/Rule/Collection/RuleContainerObservableList.cs @@ -14,8 +14,6 @@ public class RuleContainerObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Rule/Collection/RulesMatcherElementObservableList.cs b/Runtime/Rule/Collection/RulesMatcherElementObservableList.cs index ca553663..59819c04 100644 --- a/Runtime/Rule/Collection/RulesMatcherElementObservableList.cs +++ b/Runtime/Rule/Collection/RulesMatcherElementObservableList.cs @@ -14,8 +14,6 @@ public class RulesMatcherElementObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Rule/RuleContainer.cs b/Runtime/Rule/RuleContainer.cs index fd3aed7e..7ab54fef 100644 --- a/Runtime/Rule/RuleContainer.cs +++ b/Runtime/Rule/RuleContainer.cs @@ -7,7 +7,5 @@ /// A proxy class used to make a interface appear in the Unity Inspector. /// [Serializable] - public sealed class RuleContainer : InterfaceContainer - { - } + public sealed class RuleContainer : InterfaceContainer { } } \ No newline at end of file diff --git a/Runtime/Tracking/CameraRig/Collection/LinkedAliasAssociationCollectionObservableList.cs b/Runtime/Tracking/CameraRig/Collection/LinkedAliasAssociationCollectionObservableList.cs index 678c73da..638d4448 100644 --- a/Runtime/Tracking/CameraRig/Collection/LinkedAliasAssociationCollectionObservableList.cs +++ b/Runtime/Tracking/CameraRig/Collection/LinkedAliasAssociationCollectionObservableList.cs @@ -14,8 +14,6 @@ public class LinkedAliasAssociationCollectionObservableList : DefaultObservableL /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Tracking/CameraRig/Operation/Extraction/PlayAreaDimensionsExtractor.cs b/Runtime/Tracking/CameraRig/Operation/Extraction/PlayAreaDimensionsExtractor.cs index 9d13913f..bf74f346 100644 --- a/Runtime/Tracking/CameraRig/Operation/Extraction/PlayAreaDimensionsExtractor.cs +++ b/Runtime/Tracking/CameraRig/Operation/Extraction/PlayAreaDimensionsExtractor.cs @@ -15,9 +15,7 @@ public class PlayAreaDimensionsExtractor : Vector3Extractor value. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override Vector3? ExtractValue() diff --git a/Runtime/Tracking/Collision/Active/ActiveCollisionConsumer.cs b/Runtime/Tracking/Collision/Active/ActiveCollisionConsumer.cs index df0a9248..3422c353 100644 --- a/Runtime/Tracking/Collision/Active/ActiveCollisionConsumer.cs +++ b/Runtime/Tracking/Collision/Active/ActiveCollisionConsumer.cs @@ -56,9 +56,7 @@ public void Clear() /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The highest level container of the consumer to allow for nested consumers. diff --git a/Runtime/Tracking/Collision/Active/ActiveCollisionPublisher.cs b/Runtime/Tracking/Collision/Active/ActiveCollisionPublisher.cs index 29727f32..58959f87 100644 --- a/Runtime/Tracking/Collision/Active/ActiveCollisionPublisher.cs +++ b/Runtime/Tracking/Collision/Active/ActiveCollisionPublisher.cs @@ -47,9 +47,7 @@ public List ActiveCollisions /// Defines the event for the output . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The data to publish to any available consumers. diff --git a/Runtime/Tracking/Collision/Active/ActiveCollisionsContainer.cs b/Runtime/Tracking/Collision/Active/ActiveCollisionsContainer.cs index 6bbc121b..1ce30cea 100644 --- a/Runtime/Tracking/Collision/Active/ActiveCollisionsContainer.cs +++ b/Runtime/Tracking/Collision/Active/ActiveCollisionsContainer.cs @@ -51,9 +51,7 @@ public void Clear() /// Defines the event with the . /// [Serializable] - public class ActiveCollisionUnityEvent : UnityEvent - { - } + public class ActiveCollisionUnityEvent : UnityEvent { } #region Validity Settings /// diff --git a/Runtime/Tracking/Collision/Active/CollisionPointContainer.cs b/Runtime/Tracking/Collision/Active/CollisionPointContainer.cs index 854b79f8..55c2389f 100644 --- a/Runtime/Tracking/Collision/Active/CollisionPointContainer.cs +++ b/Runtime/Tracking/Collision/Active/CollisionPointContainer.cs @@ -17,9 +17,7 @@ public class CollisionPointContainer : MonoBehaviour /// Defines the event for the generated collision point . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Determines whether the collision point parent is the that contains a or to just search for the containing . diff --git a/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionConsumerEventProxyEmitter.cs b/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionConsumerEventProxyEmitter.cs index 59f88eab..44f4a820 100644 --- a/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionConsumerEventProxyEmitter.cs +++ b/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionConsumerEventProxyEmitter.cs @@ -14,9 +14,7 @@ public class ActiveCollisionConsumerEventProxyEmitter : RestrictableSingleEventP /// Defines the event with the specified state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override object GetTargetToCheck() diff --git a/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionsContainerEventProxyEmitter.cs b/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionsContainerEventProxyEmitter.cs index 28456d23..75f2290b 100644 --- a/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionsContainerEventProxyEmitter.cs +++ b/Runtime/Tracking/Collision/Active/Event/Proxy/ActiveCollisionsContainerEventProxyEmitter.cs @@ -14,8 +14,6 @@ public class ActiveCollisionsContainerEventProxyEmitter : SingleEventProxyEmitte /// Defines the event with the specified state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierContainerExtractor.cs b/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierContainerExtractor.cs index 1f868b36..8403e6ff 100644 --- a/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierContainerExtractor.cs +++ b/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierContainerExtractor.cs @@ -14,9 +14,7 @@ public class NotifierContainerExtractor : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override GameObject ExtractValue() diff --git a/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierTargetExtractor.cs b/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierTargetExtractor.cs index 53c6a810..dde74c82 100644 --- a/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierTargetExtractor.cs +++ b/Runtime/Tracking/Collision/Active/Operation/Extraction/NotifierTargetExtractor.cs @@ -15,9 +15,7 @@ public class NotifierTargetExtractor : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override GameObject ExtractValue() diff --git a/Runtime/Tracking/Collision/Active/Operation/Extraction/PublisherContainerExtractor.cs b/Runtime/Tracking/Collision/Active/Operation/Extraction/PublisherContainerExtractor.cs index a05cce5b..3e1b9201 100644 --- a/Runtime/Tracking/Collision/Active/Operation/Extraction/PublisherContainerExtractor.cs +++ b/Runtime/Tracking/Collision/Active/Operation/Extraction/PublisherContainerExtractor.cs @@ -14,9 +14,7 @@ public class PublisherContainerExtractor : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Extracts the source container from the given publisher contained within the . diff --git a/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs b/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs index dcddf024..b2593163 100644 --- a/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs +++ b/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs @@ -39,9 +39,7 @@ public enum RuleSourceType /// Defines the event with the specified state. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// protected override object GetTargetToCheck() diff --git a/Runtime/Tracking/Follow/ObjectDistanceComparator.cs b/Runtime/Tracking/Follow/ObjectDistanceComparator.cs index 3f9c2807..5a9197c3 100644 --- a/Runtime/Tracking/Follow/ObjectDistanceComparator.cs +++ b/Runtime/Tracking/Follow/ObjectDistanceComparator.cs @@ -59,9 +59,7 @@ public void Clear() /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The source of the distance measurement. diff --git a/Runtime/Tracking/Follow/ObjectFollower.cs b/Runtime/Tracking/Follow/ObjectFollower.cs index 1ab0e631..ca647dca 100644 --- a/Runtime/Tracking/Follow/ObjectFollower.cs +++ b/Runtime/Tracking/Follow/ObjectFollower.cs @@ -65,9 +65,7 @@ public void Clear() /// Defines the event with the . /// [Serializable] - public class FollowEvent : UnityEvent - { - } + public class FollowEvent : UnityEvent { } /// /// A collection of target offsets to offset the against the source whilst following. The for the target offset must be a child of the corresponding target. diff --git a/Runtime/Tracking/Follow/Operation/Extraction/ObjectDistanceComparatorEventDataExtractor.cs b/Runtime/Tracking/Follow/Operation/Extraction/ObjectDistanceComparatorEventDataExtractor.cs index 7bbcf1f8..4619881e 100644 --- a/Runtime/Tracking/Follow/Operation/Extraction/ObjectDistanceComparatorEventDataExtractor.cs +++ b/Runtime/Tracking/Follow/Operation/Extraction/ObjectDistanceComparatorEventDataExtractor.cs @@ -15,17 +15,13 @@ public class ObjectDistanceComparatorEventDataExtractor : MonoBehaviour /// Defines the event with the specified . /// [Serializable] - public class Vector3UnityEvent : UnityEvent - { - } + public class Vector3UnityEvent : UnityEvent { } /// /// Defines the event with the specified . /// [Serializable] - public class FloatUnityEvent : UnityEvent - { - } + public class FloatUnityEvent : UnityEvent { } /// /// Emitted when the is extracted. diff --git a/Runtime/Tracking/Modification/Operation/Extraction/TransformPropertyApplierEventDataExtractor.cs b/Runtime/Tracking/Modification/Operation/Extraction/TransformPropertyApplierEventDataExtractor.cs index 175a6489..38453012 100644 --- a/Runtime/Tracking/Modification/Operation/Extraction/TransformPropertyApplierEventDataExtractor.cs +++ b/Runtime/Tracking/Modification/Operation/Extraction/TransformPropertyApplierEventDataExtractor.cs @@ -16,9 +16,7 @@ public class TransformPropertyApplierEventDataExtractor : MonoBehaviour /// Defines the event with the specified . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// Emitted when the is extracted. diff --git a/Runtime/Tracking/Modification/TransformPropertyApplier.cs b/Runtime/Tracking/Modification/TransformPropertyApplier.cs index a8ab9cde..afba13f0 100644 --- a/Runtime/Tracking/Modification/TransformPropertyApplier.cs +++ b/Runtime/Tracking/Modification/TransformPropertyApplier.cs @@ -59,9 +59,7 @@ public void Clear() /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// A reusable instance of . diff --git a/Runtime/Tracking/Query/ObscuranceQuery.cs b/Runtime/Tracking/Query/ObscuranceQuery.cs index db362387..0043c612 100644 --- a/Runtime/Tracking/Query/ObscuranceQuery.cs +++ b/Runtime/Tracking/Query/ObscuranceQuery.cs @@ -24,9 +24,7 @@ public class ObscuranceQuery : MonoBehaviour, IProcessable /// Defines the event with the of s. /// [Serializable] - public class HitEvent : UnityEvent> - { - } + public class HitEvent : UnityEvent> { } public class MissingColliderException : Exception { diff --git a/Runtime/Tracking/Velocity/Collection/VelocityTrackerObservableList.cs b/Runtime/Tracking/Velocity/Collection/VelocityTrackerObservableList.cs index 4e81b15b..dbd0e10e 100644 --- a/Runtime/Tracking/Velocity/Collection/VelocityTrackerObservableList.cs +++ b/Runtime/Tracking/Velocity/Collection/VelocityTrackerObservableList.cs @@ -14,8 +14,6 @@ public class VelocityTrackerObservableList : DefaultObservableList. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } } } \ No newline at end of file diff --git a/Runtime/Tracking/Velocity/VelocityEmitter.cs b/Runtime/Tracking/Velocity/VelocityEmitter.cs index 49589252..5202c2e2 100644 --- a/Runtime/Tracking/Velocity/VelocityEmitter.cs +++ b/Runtime/Tracking/Velocity/VelocityEmitter.cs @@ -17,17 +17,13 @@ public class VelocityEmitter : MonoBehaviour /// Defines the event with the . /// [Serializable] - public class Vector3UnityEvent : UnityEvent - { - } + public class Vector3UnityEvent : UnityEvent { } /// /// Defines the event with the . /// [Serializable] - public class FloatUnityEvent : UnityEvent - { - } + public class FloatUnityEvent : UnityEvent { } /// /// The source to receive the velocity data from. diff --git a/Runtime/Utility/CountdownTimer.cs b/Runtime/Utility/CountdownTimer.cs index 3108f7d8..b2ea6842 100644 --- a/Runtime/Utility/CountdownTimer.cs +++ b/Runtime/Utility/CountdownTimer.cs @@ -17,9 +17,7 @@ public class CountdownTimer : MonoBehaviour /// Defines the event with the specified . /// [Serializable] - public class FloatUnityEvent : UnityEvent - { - } + public class FloatUnityEvent : UnityEvent { } /// /// The time to start the countdown at. diff --git a/Runtime/Utility/InterfaceContainer.cs b/Runtime/Utility/InterfaceContainer.cs index 6928af8a..0b4d2647 100644 --- a/Runtime/Utility/InterfaceContainer.cs +++ b/Runtime/Utility/InterfaceContainer.cs @@ -57,9 +57,7 @@ public TInterface Interface private TInterface _interface; /// - public void OnBeforeSerialize() - { - } + public void OnBeforeSerialize() { } /// public void OnAfterDeserialize() diff --git a/Runtime/Visual/CameraColorOverlay.cs b/Runtime/Visual/CameraColorOverlay.cs index 4dc72492..6de9a837 100644 --- a/Runtime/Visual/CameraColorOverlay.cs +++ b/Runtime/Visual/CameraColorOverlay.cs @@ -50,9 +50,7 @@ public void Clear() /// Defines the event with the . /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } /// /// The rules to determine which scene cameras to apply the overlay to. diff --git a/Tests/Editor/Data/Operation/Extraction/GameObjectExtractorTest.cs b/Tests/Editor/Data/Operation/Extraction/GameObjectExtractorTest.cs index 4f7e4908..e2dcac0a 100644 --- a/Tests/Editor/Data/Operation/Extraction/GameObjectExtractorTest.cs +++ b/Tests/Editor/Data/Operation/Extraction/GameObjectExtractorTest.cs @@ -107,9 +107,7 @@ public class GameObjectExtractorImplementation : GameObjectExtractor. /// [Serializable] - public class UnityEvent : UnityEvent - { - } + public class UnityEvent : UnityEvent { } public void SetResult(GameObject result) { diff --git a/Tests/Editor/Rule/AnyBehaviourEnabledRuleTest.cs b/Tests/Editor/Rule/AnyBehaviourEnabledRuleTest.cs index 54e96e2c..df2ae16b 100644 --- a/Tests/Editor/Rule/AnyBehaviourEnabledRuleTest.cs +++ b/Tests/Editor/Rule/AnyBehaviourEnabledRuleTest.cs @@ -154,8 +154,6 @@ public IEnumerator AcceptsInactiveComponent() Assert.IsFalse(container.Accepts(containingObject)); } - private class TestScript : MonoBehaviour - { - } + private class TestScript : MonoBehaviour { } } } \ No newline at end of file diff --git a/Tests/Editor/Rule/AnyComponentTypeRuleTest.cs b/Tests/Editor/Rule/AnyComponentTypeRuleTest.cs index ef407d1f..6d040345 100644 --- a/Tests/Editor/Rule/AnyComponentTypeRuleTest.cs +++ b/Tests/Editor/Rule/AnyComponentTypeRuleTest.cs @@ -135,8 +135,6 @@ public IEnumerator AcceptsInactiveComponent() Assert.IsFalse(container.Accepts(containingObject)); } - private class TestScript : MonoBehaviour - { - } + private class TestScript : MonoBehaviour { } } } \ No newline at end of file diff --git a/Tests/Utility/Stub/RuleStub.cs b/Tests/Utility/Stub/RuleStub.cs index 767c2fd3..7da39121 100644 --- a/Tests/Utility/Stub/RuleStub.cs +++ b/Tests/Utility/Stub/RuleStub.cs @@ -3,7 +3,5 @@ using UnityEngine; [AddComponentMenu("")] - public class RuleStub : MonoBehaviour - { - } + public class RuleStub : MonoBehaviour { } } \ No newline at end of file From f1e70c8ffad0795ac3d30a47b642071a481e8b10 Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Thu, 9 Jul 2020 18:13:32 +0100 Subject: [PATCH 6/9] feat(Yield): add ability to emit an event after a yield instruction The new Yield events provide the ability to trigger some action after a yield instruction has completed such as seconds passed or at end of frame. This can be used in conjunction with the Proxy events to first store the payload in the Proxy then trigger the emit after the yield instruction has completed. --- Runtime/Event/Yield.meta | 8 ++ .../Yield/WaitForEndOfFrameYieldEmitter.cs | 22 +++++ .../WaitForEndOfFrameYieldEmitter.cs.meta | 11 +++ .../Yield/WaitForFixedUpdateYieldEmitter.cs | 22 +++++ .../WaitForFixedUpdateYieldEmitter.cs.meta | 11 +++ .../WaitForSecondsRealtimeYieldEmitter.cs | 46 ++++++++++ ...WaitForSecondsRealtimeYieldEmitter.cs.meta | 11 +++ .../Event/Yield/WaitForSecondsYieldEmitter.cs | 46 ++++++++++ .../Yield/WaitForSecondsYieldEmitter.cs.meta | 11 +++ Runtime/Event/Yield/YieldEmitter.cs | 92 +++++++++++++++++++ Runtime/Event/Yield/YieldEmitter.cs.meta | 11 +++ Tests/Editor/Event/Yield.meta | 8 ++ .../WaitForEndOfFrameYieldEmitterTest.cs | 80 ++++++++++++++++ .../WaitForEndOfFrameYieldEmitterTest.cs.meta | 11 +++ .../WaitForFixedUpdateYieldEmitterTest.cs | 80 ++++++++++++++++ ...WaitForFixedUpdateYieldEmitterTest.cs.meta | 11 +++ .../WaitForSecondsRealtimeYieldEmitterTest.cs | 84 +++++++++++++++++ ...ForSecondsRealtimeYieldEmitterTest.cs.meta | 11 +++ .../Yield/WaitForSecondsYieldEmitterTest.cs | 84 +++++++++++++++++ .../WaitForSecondsYieldEmitterTest.cs.meta | 11 +++ 20 files changed, 671 insertions(+) create mode 100644 Runtime/Event/Yield.meta create mode 100644 Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs create mode 100644 Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs.meta create mode 100644 Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs create mode 100644 Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs.meta create mode 100644 Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs create mode 100644 Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs.meta create mode 100644 Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs create mode 100644 Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs.meta create mode 100644 Runtime/Event/Yield/YieldEmitter.cs create mode 100644 Runtime/Event/Yield/YieldEmitter.cs.meta create mode 100644 Tests/Editor/Event/Yield.meta create mode 100644 Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs create mode 100644 Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs.meta create mode 100644 Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs create mode 100644 Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs.meta create mode 100644 Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs create mode 100644 Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs.meta create mode 100644 Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs create mode 100644 Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs.meta diff --git a/Runtime/Event/Yield.meta b/Runtime/Event/Yield.meta new file mode 100644 index 00000000..0002a152 --- /dev/null +++ b/Runtime/Event/Yield.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3b0262f9c5048974c86fe6d3dd904a0f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs b/Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs new file mode 100644 index 00000000..65aaa5b7 --- /dev/null +++ b/Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs @@ -0,0 +1,22 @@ +namespace Zinnia.Event.Yield +{ + using System.Collections; + using UnityEngine; + + /// + /// Yields at the End of the Frame. + /// + public class WaitForEndOfFrameYieldEmitter : YieldEmitter + { + /// + /// The instruction to yield upon. + /// + protected WaitForEndOfFrame yieldInstruction = new WaitForEndOfFrame(); + + /// + protected override IEnumerator YieldOn() + { + yield return yieldInstruction; + } + } +} \ No newline at end of file diff --git a/Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs.meta b/Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs.meta new file mode 100644 index 00000000..40ca3835 --- /dev/null +++ b/Runtime/Event/Yield/WaitForEndOfFrameYieldEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5f242ad1805431946acc4c338fa4d88b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs b/Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs new file mode 100644 index 00000000..bebf03ef --- /dev/null +++ b/Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs @@ -0,0 +1,22 @@ +namespace Zinnia.Event.Yield +{ + using System.Collections; + using UnityEngine; + + /// + /// Yields after the FixedUpdate moment. + /// + public class WaitForFixedUpdateYieldEmitter : YieldEmitter + { + /// + /// The instruction to yield upon. + /// + protected WaitForFixedUpdate yieldInstruction = new WaitForFixedUpdate(); + + /// + protected override IEnumerator YieldOn() + { + yield return yieldInstruction; + } + } +} \ No newline at end of file diff --git a/Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs.meta b/Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs.meta new file mode 100644 index 00000000..63ee37e9 --- /dev/null +++ b/Runtime/Event/Yield/WaitForFixedUpdateYieldEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9250bdac21f2ad247a1301fc5d4c9d95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs b/Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs new file mode 100644 index 00000000..d1d69904 --- /dev/null +++ b/Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs @@ -0,0 +1,46 @@ +namespace Zinnia.Event.Yield +{ + using Malimbe.MemberChangeMethod; + using Malimbe.PropertySerializationAttribute; + using Malimbe.XmlDocumentationAttribute; + using System.Collections; + using UnityEngine; + + /// + /// Yields after the have passed in unscaled time. + /// + public class WaitForSecondsRealtimeYieldEmitter : YieldEmitter + { + /// + /// The number of seconds to wait in unscaled time before yielding. + /// + [Serialized] + [field: DocumentedByXml] + public float SecondsToWait { get; set; } + + /// + /// The instruction to yield upon. + /// + protected WaitForSecondsRealtime yieldInstruction; + + /// + protected override IEnumerator YieldOn() + { + yield return yieldInstruction; + } + + protected virtual void OnEnable() + { + OnAfterSecondsToWaitChange(); + } + + /// + /// Called after has been changed. + /// + [CalledAfterChangeOf(nameof(SecondsToWait))] + protected virtual void OnAfterSecondsToWaitChange() + { + yieldInstruction = new WaitForSecondsRealtime(SecondsToWait); + } + } +} \ No newline at end of file diff --git a/Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs.meta b/Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs.meta new file mode 100644 index 00000000..78046a38 --- /dev/null +++ b/Runtime/Event/Yield/WaitForSecondsRealtimeYieldEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e91d2c0f32698545a930a1882828e35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs b/Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs new file mode 100644 index 00000000..b8ceb105 --- /dev/null +++ b/Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs @@ -0,0 +1,46 @@ +namespace Zinnia.Event.Yield +{ + using Malimbe.MemberChangeMethod; + using Malimbe.PropertySerializationAttribute; + using Malimbe.XmlDocumentationAttribute; + using System.Collections; + using UnityEngine; + + /// + /// Yields after the have passed in scaled time by . + /// + public class WaitForSecondsYieldEmitter : YieldEmitter + { + /// + /// The number of seconds to wait before yielding. + /// + [Serialized] + [field: DocumentedByXml] + public float SecondsToWait { get; set; } + + /// + /// The instruction to yield upon. + /// + protected WaitForSeconds yieldInstruction; + + /// + protected override IEnumerator YieldOn() + { + yield return yieldInstruction; + } + + protected virtual void OnEnable() + { + OnAfterSecondsToWaitChange(); + } + + /// + /// Called after has been changed. + /// + [CalledAfterChangeOf(nameof(SecondsToWait))] + protected virtual void OnAfterSecondsToWaitChange() + { + yieldInstruction = new WaitForSeconds(SecondsToWait); + } + } +} \ No newline at end of file diff --git a/Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs.meta b/Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs.meta new file mode 100644 index 00000000..27eaf674 --- /dev/null +++ b/Runtime/Event/Yield/WaitForSecondsYieldEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 539bea0147d8c64449e107944cd11162 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Event/Yield/YieldEmitter.cs b/Runtime/Event/Yield/YieldEmitter.cs new file mode 100644 index 00000000..2447c16c --- /dev/null +++ b/Runtime/Event/Yield/YieldEmitter.cs @@ -0,0 +1,92 @@ +namespace Zinnia.Event.Yield +{ + using Malimbe.BehaviourStateRequirementMethod; + using System.Collections; + using UnityEngine; + using UnityEngine.Events; + + /// + /// Emits an event when a coroutine has complete after the yield. + /// + public abstract class YieldEmitter : MonoBehaviour + { + /// + /// Emitted when the coroutine has yielded successfully. + /// + public UnityEvent Yielded = new UnityEvent(); + /// + /// Emitted when the coroutine is cancelled before the yield completes. + /// + public UnityEvent Cancelled = new UnityEvent(); + + /// + /// Whether the routine is currently running. + /// + public bool IsRunning => routine != null; + + /// + /// The routine to process. + /// + protected Coroutine routine; + + /// + /// Cancels any existing yield check before beginning a new one. + /// + [RequiresBehaviourState] + public virtual void CancelThenBegin() + { + Cancel(); + Begin(); + } + + /// + /// Starts a new yield check if one is not already running. + /// + [RequiresBehaviourState] + public virtual void Begin() + { + if (routine == null) + { + routine = StartCoroutine(Routine()); + } + } + + /// + /// Cancels any existing yield check. + /// + public virtual void Cancel() + { + if (routine != null) + { + StopCoroutine(routine); + Cancelled?.Invoke(); + routine = null; + } + } + + /// + /// The instruction to yield on. + /// + /// The enumerator to yield on. + protected abstract IEnumerator YieldOn(); + + protected virtual void OnDisable() + { + Cancel(); + } + + /// + /// The routine to perform the yield check with. + /// + /// An Enumerator to manage the running of the Coroutine. + protected virtual IEnumerator Routine() + { + yield return YieldOn(); + if (routine != null) + { + Yielded?.Invoke(); + } + routine = null; + } + } +} \ No newline at end of file diff --git a/Runtime/Event/Yield/YieldEmitter.cs.meta b/Runtime/Event/Yield/YieldEmitter.cs.meta new file mode 100644 index 00000000..62f3ebc5 --- /dev/null +++ b/Runtime/Event/Yield/YieldEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 032081ab0e47ab5428ace512c09a0c1d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Event/Yield.meta b/Tests/Editor/Event/Yield.meta new file mode 100644 index 00000000..b9ae9402 --- /dev/null +++ b/Tests/Editor/Event/Yield.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 04cf5fb00f5f17b44a3ed686d914f133 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs b/Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs new file mode 100644 index 00000000..46e31238 --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs @@ -0,0 +1,80 @@ +using Zinnia.Event.Yield; + +namespace Test.Zinnia.Event.Yield +{ + using NUnit.Framework; + using System.Collections; + using Test.Zinnia.Utility.Mock; + using UnityEngine; + using UnityEngine.TestTools; + using Assert = UnityEngine.Assertions.Assert; + + public class WaitForEndOfFrameYieldEmitterTest + { + private GameObject containingObject; + private WaitForEndOfFrameYieldEmitter subject; + + [SetUp] + public void SetUp() + { + containingObject = new GameObject(); + subject = containingObject.AddComponent(); + } + + [TearDown] + public void TearDown() + { + Object.DestroyImmediate(subject); + Object.DestroyImmediate(containingObject); + } + + [UnityTest] + public IEnumerator Yielded() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + yield return null; + } + + Assert.IsTrue(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + } + + [UnityTest] + public IEnumerator Cancelled() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + subject.Cancel(); + yield return null; + } + + Assert.IsFalse(yieldedMock.Received); + Assert.IsTrue(cancelledMock.Received); + } + } +} \ No newline at end of file diff --git a/Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs.meta b/Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs.meta new file mode 100644 index 00000000..92ec97b4 --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForEndOfFrameYieldEmitterTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6af7aa34b277e6144bfabe1a33941984 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs b/Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs new file mode 100644 index 00000000..dfdf7dd1 --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs @@ -0,0 +1,80 @@ +using Zinnia.Event.Yield; + +namespace Test.Zinnia.Event.Yield +{ + using NUnit.Framework; + using System.Collections; + using Test.Zinnia.Utility.Mock; + using UnityEngine; + using UnityEngine.TestTools; + using Assert = UnityEngine.Assertions.Assert; + + public class WaitForFixedUpdateYieldEmitterTest + { + private GameObject containingObject; + private WaitForFixedUpdateYieldEmitter subject; + + [SetUp] + public void SetUp() + { + containingObject = new GameObject(); + subject = containingObject.AddComponent(); + } + + [TearDown] + public void TearDown() + { + Object.DestroyImmediate(subject); + Object.DestroyImmediate(containingObject); + } + + [UnityTest] + public IEnumerator Yielded() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + yield return null; + } + + Assert.IsTrue(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + } + + [UnityTest] + public IEnumerator Cancelled() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + subject.Cancel(); + yield return null; + } + + Assert.IsFalse(yieldedMock.Received); + Assert.IsTrue(cancelledMock.Received); + } + } +} \ No newline at end of file diff --git a/Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs.meta b/Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs.meta new file mode 100644 index 00000000..65fdeecc --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForFixedUpdateYieldEmitterTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 999279a642b4d494fbceac09f5759636 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs b/Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs new file mode 100644 index 00000000..dd4e46c3 --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs @@ -0,0 +1,84 @@ +using Zinnia.Event.Yield; + +namespace Test.Zinnia.Event.Yield +{ + using NUnit.Framework; + using System.Collections; + using Test.Zinnia.Utility.Mock; + using UnityEngine; + using UnityEngine.TestTools; + using Assert = UnityEngine.Assertions.Assert; + + public class WaitForSecondsRealtimeYieldEmitterTest + { + private GameObject containingObject; + private WaitForSecondsRealtimeYieldEmitter subject; + + [SetUp] + public void SetUp() + { + containingObject = new GameObject(); + subject = containingObject.AddComponent(); + } + + [TearDown] + public void TearDown() + { + Object.DestroyImmediate(subject); + Object.DestroyImmediate(containingObject); + } + + [UnityTest] + public IEnumerator Yielded() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + subject.SecondsToWait = 1f; + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + yield return null; + } + + Assert.IsTrue(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + } + + [UnityTest] + public IEnumerator Cancelled() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + subject.SecondsToWait = 1f; + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + subject.Cancel(); + yield return null; + } + + Assert.IsFalse(yieldedMock.Received); + Assert.IsTrue(cancelledMock.Received); + } + } +} \ No newline at end of file diff --git a/Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs.meta b/Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs.meta new file mode 100644 index 00000000..2a091b9f --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForSecondsRealtimeYieldEmitterTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3140db517923ac548bf420779cc71320 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs b/Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs new file mode 100644 index 00000000..f84a98b4 --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs @@ -0,0 +1,84 @@ +using Zinnia.Event.Yield; + +namespace Test.Zinnia.Event.Yield +{ + using NUnit.Framework; + using System.Collections; + using Test.Zinnia.Utility.Mock; + using UnityEngine; + using UnityEngine.TestTools; + using Assert = UnityEngine.Assertions.Assert; + + public class WaitForSecondsYieldEmitterTest + { + private GameObject containingObject; + private WaitForSecondsYieldEmitter subject; + + [SetUp] + public void SetUp() + { + containingObject = new GameObject(); + subject = containingObject.AddComponent(); + } + + [TearDown] + public void TearDown() + { + Object.DestroyImmediate(subject); + Object.DestroyImmediate(containingObject); + } + + [UnityTest] + public IEnumerator Yielded() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + subject.SecondsToWait = 1f; + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + yield return null; + } + + Assert.IsTrue(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + } + + [UnityTest] + public IEnumerator Cancelled() + { + UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); + UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); + subject.Yielded.AddListener(yieldedMock.Listen); + subject.Cancelled.AddListener(cancelledMock.Listen); + + subject.SecondsToWait = 1f; + + yield return null; + + Assert.IsFalse(yieldedMock.Received); + Assert.IsFalse(cancelledMock.Received); + + subject.Begin(); + + while (subject.IsRunning) + { + subject.Cancel(); + yield return null; + } + + Assert.IsFalse(yieldedMock.Received); + Assert.IsTrue(cancelledMock.Received); + } + } +} \ No newline at end of file diff --git a/Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs.meta b/Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs.meta new file mode 100644 index 00000000..3913335b --- /dev/null +++ b/Tests/Editor/Event/Yield/WaitForSecondsYieldEmitterTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: adf54c562f8c02e4e8463bb1f310a2e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 4617d6c0868e319e2edaa8860f556465f3bffe2c Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Fri, 10 Jul 2020 13:42:12 +0100 Subject: [PATCH 7/9] fix(Attribute): record MinMaxRange value changes on prefab instance There is an issue where the MinMaxRange control will reset the value back to the previous value when it is used within a prefab. The solution seems to be to record the prefab instance property modification after the custom FloatRange value has been set through the Supyrb `SetValue` extension, which doesn't set the value via the SerializedProperty because that is not supported in Unity on custom data types. The issue only seems to present itself when changing the value between varying negative values: * -0.5 * -0.2 * -0.5 (reverts to 0) --- Editor/Data/Attribute/MinMaxRangeAttributeDrawer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Editor/Data/Attribute/MinMaxRangeAttributeDrawer.cs b/Editor/Data/Attribute/MinMaxRangeAttributeDrawer.cs index a5ab00ca..143b5764 100644 --- a/Editor/Data/Attribute/MinMaxRangeAttributeDrawer.cs +++ b/Editor/Data/Attribute/MinMaxRangeAttributeDrawer.cs @@ -29,6 +29,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { Undo.RecordObject(property.serializedObject.targetObject, property.displayName); property.SetValue(new FloatRange(output)); + if (property.isInstantiatedPrefab) + { + PrefabUtility.RecordPrefabInstancePropertyModifications(property.serializedObject.targetObject); + } } foundGeneric = true; From 33463ce4ce4fcccf8578472295774c69e73ae98b Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Thu, 9 Jul 2020 22:25:19 +0100 Subject: [PATCH 8/9] feat(Extension): add enum extension/helper methods A couple of new Enum helper methods have been added that make getting an enum easier by either being able to provide the index of the enum to return or by getting the enum by string name. The PointerElementPropertyMutator has been updated to take advantage of this new method. --- Runtime/Extension/EnumExtensions.cs | 33 ++++++++++++++++ Runtime/Extension/EnumExtensions.cs.meta | 11 ++++++ .../Mutation/PointerElementPropertyMutator.cs | 2 +- Tests/Editor/Extension/EnumExtensionsTest.cs | 39 +++++++++++++++++++ .../Extension/EnumExtensionsTest.cs.meta | 11 ++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 Runtime/Extension/EnumExtensions.cs create mode 100644 Runtime/Extension/EnumExtensions.cs.meta create mode 100644 Tests/Editor/Extension/EnumExtensionsTest.cs create mode 100644 Tests/Editor/Extension/EnumExtensionsTest.cs.meta diff --git a/Runtime/Extension/EnumExtensions.cs b/Runtime/Extension/EnumExtensions.cs new file mode 100644 index 00000000..9e67ab5c --- /dev/null +++ b/Runtime/Extension/EnumExtensions.cs @@ -0,0 +1,33 @@ +namespace Zinnia.Extension +{ + using System; + using UnityEngine; + + /// + /// Static methods for the Type. + /// + public static class EnumExtensions + { + /// + /// Gets the value based on the given index. + /// + /// The type. + /// The index to retrieve from. In case this index is out of bounds for the it will be clamped within the valid bounds. + /// The value for the index. + public static T GetByIndex(int index) + { + return (T)(object)Mathf.Clamp(index, 0, Enum.GetValues(typeof(T)).Length - 1); + } + + /// + /// Gets the value based of the representation of the type. + /// + /// The type. + /// The type representation. + /// The value for the type representation. + public static T GetByString(string value) + { + return (T)Enum.Parse(typeof(T), value.ToString(), true); + } + } +} \ No newline at end of file diff --git a/Runtime/Extension/EnumExtensions.cs.meta b/Runtime/Extension/EnumExtensions.cs.meta new file mode 100644 index 00000000..19f885af --- /dev/null +++ b/Runtime/Extension/EnumExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b5677211369f13641a0646452439b68a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Pointer/Operation/Mutation/PointerElementPropertyMutator.cs b/Runtime/Pointer/Operation/Mutation/PointerElementPropertyMutator.cs index 11b38b35..a215824c 100644 --- a/Runtime/Pointer/Operation/Mutation/PointerElementPropertyMutator.cs +++ b/Runtime/Pointer/Operation/Mutation/PointerElementPropertyMutator.cs @@ -66,7 +66,7 @@ public virtual void SetTarget(GameObject target) /// The index of the . public virtual void SetElementVisibility(int elementVisibilityIndex) { - ElementVisibility = (PointerElement.Visibility)Mathf.Clamp(elementVisibilityIndex, 0, System.Enum.GetValues(typeof(PointerElement.Visibility)).Length); + ElementVisibility = EnumExtensions.GetByIndex(elementVisibilityIndex); } /// diff --git a/Tests/Editor/Extension/EnumExtensionsTest.cs b/Tests/Editor/Extension/EnumExtensionsTest.cs new file mode 100644 index 00000000..3cddb909 --- /dev/null +++ b/Tests/Editor/Extension/EnumExtensionsTest.cs @@ -0,0 +1,39 @@ +using Zinnia.Extension; + +namespace Test.Zinnia.Extension +{ + using NUnit.Framework; + using Assert = UnityEngine.Assertions.Assert; + + public class EnumExtensionsTest + { + protected enum Test + { + First, + Second, + Third + } + + [Test] + public void GetByIndex() + { + Assert.AreEqual(Test.First, EnumExtensions.GetByIndex(-1)); + Assert.AreEqual(Test.First, EnumExtensions.GetByIndex(0)); + Assert.AreEqual(Test.Second, EnumExtensions.GetByIndex(1)); + Assert.AreEqual(Test.Third, EnumExtensions.GetByIndex(2)); + Assert.AreEqual(Test.Third, EnumExtensions.GetByIndex(3)); + } + + [Test] + public void GetByString() + { + Assert.AreEqual(Test.First, EnumExtensions.GetByString("first")); + Assert.AreEqual(Test.First, EnumExtensions.GetByString("First")); + Assert.AreEqual(Test.Second, EnumExtensions.GetByString("second")); + Assert.AreEqual(Test.Second, EnumExtensions.GetByString("Second")); + Assert.AreEqual(Test.Third, EnumExtensions.GetByString("third")); + Assert.AreEqual(Test.Third, EnumExtensions.GetByString("Third")); + NUnit.Framework.Assert.Throws(() => EnumExtensions.GetByString("Fourth")); + } + } +} \ No newline at end of file diff --git a/Tests/Editor/Extension/EnumExtensionsTest.cs.meta b/Tests/Editor/Extension/EnumExtensionsTest.cs.meta new file mode 100644 index 00000000..970f0b58 --- /dev/null +++ b/Tests/Editor/Extension/EnumExtensionsTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df0f9f60bb153244d843bf16677e08c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 98ae181d6909a95f38c5266c7555c447b013df7b Mon Sep 17 00:00:00 2001 From: Harvey Ball Date: Fri, 10 Jul 2020 10:53:22 +0100 Subject: [PATCH 9/9] feat(structure): provide mechanism to change properties via UnityEvents Some property types cannot be changed via UnityEvents as they are not supported in the UnityEvent inspector, such as Enums, Vectors and Vector3State. This has been fixed by adding custom setter methods that can be called via the UnityEvent inspector using primitive types that are supported to allow this data to still be set. --- Runtime/Action/SurfaceChangeAction.cs | 29 +++++++++- Runtime/Cast/ParabolicLineCast.cs | 18 +++++++ Runtime/Cast/PointsCast.cs | 6 +-- .../Extraction/TimeComponentExtractor.cs | 16 ++++-- .../Extraction/TransformDirectionExtractor.cs | 10 ++++ .../Mutation/RigidbodyPropertyMutator.cs | 54 +++++++++++++++++++ .../Mutation/TransformEulerRotationMutator.cs | 29 +++++++++- .../Mutation/TransformPositionMutator.cs | 27 ++++++++++ .../Mutation/TransformPropertyMutator.cs | 27 ++++++++++ .../Conversion/AngleToVector2Direction.cs | 18 +++++++ .../Conversion/Vector2ToAngle.cs | 27 ++++++++++ .../Conversion/Vector2ToFloat.cs | 10 ++++ .../Conversion/Vector2ToVector3.cs | 10 ++++ .../Conversion/Vector3ToFloat.cs | 10 ++++ .../Conversion/Vector3ToVector2.cs | 10 ++++ .../Transformation/FloatRangeValueRemapper.cs | 10 ++++ Runtime/Pointer/PointerElement.cs | 10 ++++ Runtime/Process/Moment/MomentProcessor.cs | 10 ++++ .../CollisionNotifierEventProxyEmitter.cs | 9 ++++ .../Proxy/ObjectFollowerEventProxyEmitter.cs | 10 ++++ .../Rotation/RotateAroundAngularVelocity.cs | 54 +++++++++++++++++++ .../TransformPositionDifferenceRotation.cs | 27 ++++++++++ .../Modification/TransformPropertyApplier.cs | 27 ++++++++++ Runtime/Tracking/SurfaceLocator.cs | 27 ++++++++++ .../Velocity/ArtificialVelocityApplier.cs | 54 +++++++++++++++++++ .../Tracking/Velocity/VelocityMultiplier.cs | 54 +++++++++++++++++++ Runtime/Visual/PointsRenderer.cs | 29 +++++++++- 27 files changed, 613 insertions(+), 9 deletions(-) diff --git a/Runtime/Action/SurfaceChangeAction.cs b/Runtime/Action/SurfaceChangeAction.cs index 76f6b95e..c336d130 100644 --- a/Runtime/Action/SurfaceChangeAction.cs +++ b/Runtime/Action/SurfaceChangeAction.cs @@ -29,7 +29,34 @@ public class SurfaceChangeAction : BooleanAction protected SurfaceData previousData; /// - /// Digests and compares the current surface to the previous surface to determine if a change has occured. + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetCheckAxisX(bool value) + { + CheckAxis = new Vector3State(value, CheckAxis.yState, CheckAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetCheckAxisY(bool value) + { + CheckAxis = new Vector3State(CheckAxis.xState, value, CheckAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetCheckAxisZ(bool value) + { + CheckAxis = new Vector3State(CheckAxis.xState, CheckAxis.yState, value); + } + + /// + /// Digests and compares the current surface to the previous surface to determine if a change has occurred. /// /// The to check on. [RequiresBehaviourState] diff --git a/Runtime/Cast/ParabolicLineCast.cs b/Runtime/Cast/ParabolicLineCast.cs index b1c49455..5f886a3d 100644 --- a/Runtime/Cast/ParabolicLineCast.cs +++ b/Runtime/Cast/ParabolicLineCast.cs @@ -53,6 +53,24 @@ public class ParabolicLineCast : PointsCast /// protected readonly List curvePoints = new List(); + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetMaximumLengthX(float value) + { + MaximumLength = new Vector2(value, MaximumLength.y); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetMaximumLengthY(float value) + { + MaximumLength = new Vector2(MaximumLength.x, value); + } + protected override void OnEnable() { base.OnEnable(); diff --git a/Runtime/Cast/PointsCast.cs b/Runtime/Cast/PointsCast.cs index 53709fbd..a8d27c62 100644 --- a/Runtime/Cast/PointsCast.cs +++ b/Runtime/Cast/PointsCast.cs @@ -40,7 +40,7 @@ public class EventData public bool IsValid { get; set; } /// - /// The points along the the most recent cast. + /// The points along the most recent cast. /// public HeapAllocationFreeReadOnlyList Points { get; set; } @@ -108,12 +108,12 @@ public class UnityEvent : UnityEvent { } /// public bool IsTargetHitValid { get; protected set; } /// - /// The points along the the most recent cast. + /// The points along the most recent cast. /// public HeapAllocationFreeReadOnlyList Points => points; /// - /// The points along the the most recent cast. + /// The points along the most recent cast. /// protected readonly List points = new List(); /// diff --git a/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs b/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs index 4b319a02..ee3d1b42 100644 --- a/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs +++ b/Runtime/Data/Operation/Extraction/TimeComponentExtractor.cs @@ -3,6 +3,7 @@ using System; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Extracts and emits the elements from . @@ -45,11 +46,11 @@ public enum TimeComponent /// TimeStepTypeDeltaTime, /// - /// The timeScale-independant time for this frame. This is the time in seconds since the start of the game. + /// The timeScale-independent time for this frame. This is the time in seconds since the start of the game. /// UnscaledTime, /// - /// The TimeScale-independant time the latest MonoBehaviour.FixedUpdate has started. This is the time in seconds since the start of the game. + /// The TimeScale-independent time the latest MonoBehaviour.FixedUpdate has started. This is the time in seconds since the start of the game. /// FixedUnscaledTime, /// @@ -69,7 +70,7 @@ public enum TimeComponent /// TimeStepTypeUnscaledDeltaTime, /// - /// Slows game playback time to allow screenshots to be saved between frames. + /// Slows game playback time to allow screen shots to be saved between frames. /// CaptureFrameRate, /// @@ -106,6 +107,15 @@ public enum TimeComponent TimeSinceLevelLoad } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetSource(int index) + { + Source = EnumExtensions.GetByIndex(index); + } + /// protected override float? ExtractValue() { diff --git a/Runtime/Data/Operation/Extraction/TransformDirectionExtractor.cs b/Runtime/Data/Operation/Extraction/TransformDirectionExtractor.cs index 5694c907..8f2ce71e 100644 --- a/Runtime/Data/Operation/Extraction/TransformDirectionExtractor.cs +++ b/Runtime/Data/Operation/Extraction/TransformDirectionExtractor.cs @@ -3,6 +3,7 @@ using Malimbe.PropertySerializationAttribute; using Malimbe.XmlDocumentationAttribute; using UnityEngine; + using Zinnia.Extension; /// /// Extracts a chosen axis of a . @@ -35,6 +36,15 @@ public enum AxisDirection [field: DocumentedByXml] public AxisDirection Direction { get; set; } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetDirection(int index) + { + Direction = EnumExtensions.GetByIndex(index); + } + /// protected override Vector3? ExtractValue() { diff --git a/Runtime/Data/Operation/Mutation/RigidbodyPropertyMutator.cs b/Runtime/Data/Operation/Mutation/RigidbodyPropertyMutator.cs index c55e8e45..4a97b51c 100644 --- a/Runtime/Data/Operation/Mutation/RigidbodyPropertyMutator.cs +++ b/Runtime/Data/Operation/Mutation/RigidbodyPropertyMutator.cs @@ -68,6 +68,33 @@ public virtual void SetTarget(GameObject target) Target = target.TryGetComponent(true, true); } + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetVelocityX(float value) + { + Velocity = new Vector3(value, Velocity.y, Velocity.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetVelocityY(float value) + { + Velocity = new Vector3(Velocity.x, value, Velocity.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetVelocityZ(float value) + { + Velocity = new Vector3(Velocity.x, Velocity.y, value); + } + /// /// Sets the velocity of the to zero. /// @@ -77,6 +104,33 @@ public virtual void ClearVelocity() Velocity = Vector3.zero; } + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetAngularVelocityX(float value) + { + AngularVelocity = new Vector3(value, AngularVelocity.y, AngularVelocity.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetAngularVelocityY(float value) + { + AngularVelocity = new Vector3(AngularVelocity.x, value, AngularVelocity.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetAngularVelocityZ(float value) + { + AngularVelocity = new Vector3(AngularVelocity.x, AngularVelocity.y, value); + } + /// /// Sets the angular velocity of the to zero. /// diff --git a/Runtime/Data/Operation/Mutation/TransformEulerRotationMutator.cs b/Runtime/Data/Operation/Mutation/TransformEulerRotationMutator.cs index 76cac548..8844fbc4 100644 --- a/Runtime/Data/Operation/Mutation/TransformEulerRotationMutator.cs +++ b/Runtime/Data/Operation/Mutation/TransformEulerRotationMutator.cs @@ -10,7 +10,7 @@ using Zinnia.Extension; /// - /// Mutates the euler rotation of a transform with an optional custom rotation origin. + /// Mutates the Euler rotation of a transform with an optional custom rotation origin. /// public class TransformEulerRotationMutator : TransformPropertyMutator { @@ -29,6 +29,33 @@ public class TransformEulerRotationMutator : TransformPropertyMutator public Vector3State ApplyOriginOnAxis { get; set; } = Vector3State.True; #endregion + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetApplyOriginOnAxisX(bool value) + { + ApplyOriginOnAxis = new Vector3State(value, ApplyOriginOnAxis.yState, ApplyOriginOnAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetApplyOriginOnAxisY(bool value) + { + ApplyOriginOnAxis = new Vector3State(ApplyOriginOnAxis.xState, value, ApplyOriginOnAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetApplyOriginOnAxisZ(bool value) + { + ApplyOriginOnAxis = new Vector3State(ApplyOriginOnAxis.xState, ApplyOriginOnAxis.yState, value); + } + /// protected override float GetGlobalAxisValue(int axis) { diff --git a/Runtime/Data/Operation/Mutation/TransformPositionMutator.cs b/Runtime/Data/Operation/Mutation/TransformPositionMutator.cs index 6ad426b6..085c0db5 100644 --- a/Runtime/Data/Operation/Mutation/TransformPositionMutator.cs +++ b/Runtime/Data/Operation/Mutation/TransformPositionMutator.cs @@ -27,6 +27,33 @@ public class TransformPositionMutator : TransformPropertyMutator public Vector3State ApplyFacingDirectionOnAxis { get; set; } = Vector3State.True; #endregion + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetApplyFacingDirectionOnAxisX(bool value) + { + ApplyFacingDirectionOnAxis = new Vector3State(value, ApplyFacingDirectionOnAxis.yState, ApplyFacingDirectionOnAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetApplyFacingDirectionOnAxisY(bool value) + { + ApplyFacingDirectionOnAxis = new Vector3State(ApplyFacingDirectionOnAxis.xState, value, ApplyFacingDirectionOnAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetApplyFacingDirectionOnAxisZ(bool value) + { + ApplyFacingDirectionOnAxis = new Vector3State(ApplyFacingDirectionOnAxis.xState, ApplyFacingDirectionOnAxis.yState, value); + } + /// protected override float GetGlobalAxisValue(int axis) { diff --git a/Runtime/Data/Operation/Mutation/TransformPropertyMutator.cs b/Runtime/Data/Operation/Mutation/TransformPropertyMutator.cs index 9f96b46e..5b4c0738 100644 --- a/Runtime/Data/Operation/Mutation/TransformPropertyMutator.cs +++ b/Runtime/Data/Operation/Mutation/TransformPropertyMutator.cs @@ -33,6 +33,33 @@ public abstract class TransformPropertyMutator : MonoBehaviour public Vector3State MutateOnAxis { get; set; } = Vector3State.True; #endregion + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetMutateOnAxisX(bool value) + { + MutateOnAxis = new Vector3State(value, MutateOnAxis.yState, MutateOnAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetMutateOnAxisY(bool value) + { + MutateOnAxis = new Vector3State(MutateOnAxis.xState, value, MutateOnAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetMutateOnAxisZ(bool value) + { + MutateOnAxis = new Vector3State(MutateOnAxis.xState, MutateOnAxis.yState, value); + } + /// /// Sets the property to the new value. /// diff --git a/Runtime/Data/Type/Transformation/Conversion/AngleToVector2Direction.cs b/Runtime/Data/Type/Transformation/Conversion/AngleToVector2Direction.cs index 335ed3eb..8c81772e 100644 --- a/Runtime/Data/Type/Transformation/Conversion/AngleToVector2Direction.cs +++ b/Runtime/Data/Type/Transformation/Conversion/AngleToVector2Direction.cs @@ -33,6 +33,24 @@ public class UnityEvent : UnityEvent { } /// protected Vector2 outputAngle; + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetDirectionX(float value) + { + Direction = new Vector2(value, Direction.y); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetDirectionY(float value) + { + Direction = new Vector2(Direction.x, value); + } + /// /// Transforms the given angle into a direction. /// diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs b/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs index 5c3a4136..d3ffbcc4 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector2ToAngle.cs @@ -64,6 +64,33 @@ public enum AngleUnit [field: DocumentedByXml] public Vector2 Origin { get; set; } = new Vector2(0f, 1f); + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetUnit(int index) + { + Unit = EnumExtensions.GetByIndex(index); + } + + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetOriginX(float value) + { + Origin = new Vector2(value, Origin.y); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetOriginY(float value) + { + Origin = new Vector2(Origin.x, value); + } + /// /// The full circle in radians. /// diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector2ToFloat.cs b/Runtime/Data/Type/Transformation/Conversion/Vector2ToFloat.cs index 427db6d7..72f44c45 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector2ToFloat.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector2ToFloat.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Transforms a to a and allows mapping of the relevant coordinates. @@ -53,6 +54,15 @@ public enum ExtractionCoordinate [field: DocumentedByXml] public ExtractionCoordinate CoordinateToExtract { get; set; } = ExtractionCoordinate.ExtractX; + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetCoordinateToExtract(int index) + { + CoordinateToExtract = EnumExtensions.GetByIndex(index); + } + /// /// Transforms the given into a . /// diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs b/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs index 0a6c2a64..af75053a 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector2ToVector3.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Transforms a to a and allows mapping of the relevant coordinates. @@ -66,6 +67,15 @@ public enum CoordinateMapType [field: DocumentedByXml] public float UnusedCoordinateValue { get; set; } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetCoordinateMap(int index) + { + CoordinateMap = EnumExtensions.GetByIndex(index); + } + /// /// Transforms the given into a . /// diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector3ToFloat.cs b/Runtime/Data/Type/Transformation/Conversion/Vector3ToFloat.cs index 2af91c15..97087dc0 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector3ToFloat.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector3ToFloat.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Transforms a to a and allows mapping of the relevant coordinates. @@ -58,6 +59,15 @@ public enum ExtractionCoordinate [field: DocumentedByXml] public ExtractionCoordinate CoordinateToExtract { get; set; } = ExtractionCoordinate.ExtractX; + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetCoordinateToExtract(int index) + { + CoordinateToExtract = EnumExtensions.GetByIndex(index); + } + /// /// Transforms the given into a . /// diff --git a/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs b/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs index 02d75d54..de576b10 100644 --- a/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs +++ b/Runtime/Data/Type/Transformation/Conversion/Vector3ToVector2.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Transforms a to a and allows mapping of the relevant coordinates. @@ -60,6 +61,15 @@ public enum CoordinateMapType [field: DocumentedByXml] public CoordinateMapType CoordinateMap { get; set; } = CoordinateMapType.XToXAndYToYExcludeZ; + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetCoordinateMap(int index) + { + CoordinateMap = EnumExtensions.GetByIndex(index); + } + /// /// Transforms the given into a . /// diff --git a/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs b/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs index 06da8762..538994a2 100644 --- a/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs +++ b/Runtime/Data/Type/Transformation/FloatRangeValueRemapper.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Transforms a by remapping from a range to a new range. @@ -60,6 +61,15 @@ public enum OutputMode [field: DocumentedByXml] public OutputMode Mode { get; set; } = OutputMode.Lerp; + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetMode(int index) + { + Mode = EnumExtensions.GetByIndex(index); + } + /// /// Transforms the given by remapping to a new range. /// diff --git a/Runtime/Pointer/PointerElement.cs b/Runtime/Pointer/PointerElement.cs index da19fd1c..5c51a57b 100644 --- a/Runtime/Pointer/PointerElement.cs +++ b/Runtime/Pointer/PointerElement.cs @@ -6,6 +6,7 @@ using Malimbe.XmlDocumentationAttribute; using UnityEngine; using UnityEngine.Events; + using Zinnia.Extension; /// /// Describes an element of the rendered . @@ -83,6 +84,15 @@ public enum Visibility /// public bool IsVisible { get; set; } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetElementVisibilityt(int index) + { + ElementVisibility = EnumExtensions.GetByIndex(index); + } + /// /// Called after has been changed. /// diff --git a/Runtime/Process/Moment/MomentProcessor.cs b/Runtime/Process/Moment/MomentProcessor.cs index e1b51394..9f1fe174 100644 --- a/Runtime/Process/Moment/MomentProcessor.cs +++ b/Runtime/Process/Moment/MomentProcessor.cs @@ -5,6 +5,7 @@ using Malimbe.XmlDocumentationAttribute; using UnityEngine; using UnityEngine.Rendering; + using Zinnia.Extension; using Zinnia.Process.Moment.Collection; /// @@ -56,6 +57,15 @@ public enum Moment [field: DocumentedByXml] public MomentProcessObservableList Processes { get; set; } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetProcessMoment(int index) + { + ProcessMoment = EnumExtensions.GetByIndex(index); + } + protected virtual void OnEnable() { SubscribeMoment(); diff --git a/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs b/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs index b2593163..1faa301d 100644 --- a/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs +++ b/Runtime/Tracking/Collision/Event/Proxy/CollisionNotifierEventProxyEmitter.cs @@ -41,6 +41,15 @@ public enum RuleSourceType [Serializable] public class UnityEvent : UnityEvent { } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetRuleSource(int index) + { + RuleSource = EnumExtensions.GetByIndex(index); + } + /// protected override object GetTargetToCheck() { diff --git a/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs b/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs index 2679538c..5ab4313f 100644 --- a/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs +++ b/Runtime/Tracking/Follow/Event/Proxy/ObjectFollowerEventProxyEmitter.cs @@ -6,6 +6,7 @@ using UnityEngine; using UnityEngine.Events; using Zinnia.Event.Proxy; + using Zinnia.Extension; public class ObjectFollowerEventProxyEmitter : RestrictableSingleEventProxyEmitter { @@ -41,6 +42,15 @@ public enum RuleSourceType [field: DocumentedByXml] public RuleSourceType RuleSource { get; set; } + /// + /// Sets the . + /// + /// The index of the . + public virtual void SetRuleSource(int index) + { + RuleSource = EnumExtensions.GetByIndex(index); + } + /// protected override object GetTargetToCheck() { diff --git a/Runtime/Tracking/Follow/Modifier/Property/Rotation/RotateAroundAngularVelocity.cs b/Runtime/Tracking/Follow/Modifier/Property/Rotation/RotateAroundAngularVelocity.cs index af737848..b5550100 100644 --- a/Runtime/Tracking/Follow/Modifier/Property/Rotation/RotateAroundAngularVelocity.cs +++ b/Runtime/Tracking/Follow/Modifier/Property/Rotation/RotateAroundAngularVelocity.cs @@ -31,6 +31,60 @@ public class RotateAroundAngularVelocity : PropertyModifier [field: DocumentedByXml] public Vector3State ApplyToAxis { get; set; } + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetSourceMultiplierX(float value) + { + SourceMultiplier = new Vector3(value, SourceMultiplier.y, SourceMultiplier.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetSourceMultiplierY(float value) + { + SourceMultiplier = new Vector3(SourceMultiplier.x, value, SourceMultiplier.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetSourceMultiplierZ(float value) + { + SourceMultiplier = new Vector3(SourceMultiplier.x, SourceMultiplier.y, value); + } + + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetApplyToAxisX(bool value) + { + ApplyToAxis = new Vector3State(value, ApplyToAxis.yState, ApplyToAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetApplyToAxisY(bool value) + { + ApplyToAxis = new Vector3State(ApplyToAxis.xState, value, ApplyToAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetApplyToAxisZ(bool value) + { + ApplyToAxis = new Vector3State(ApplyToAxis.xState, ApplyToAxis.yState, value); + } + /// /// Modifies the target rotation to match the given source rotation. /// diff --git a/Runtime/Tracking/Follow/Modifier/Property/Rotation/TransformPositionDifferenceRotation.cs b/Runtime/Tracking/Follow/Modifier/Property/Rotation/TransformPositionDifferenceRotation.cs index f183872d..f452ffa2 100644 --- a/Runtime/Tracking/Follow/Modifier/Property/Rotation/TransformPositionDifferenceRotation.cs +++ b/Runtime/Tracking/Follow/Modifier/Property/Rotation/TransformPositionDifferenceRotation.cs @@ -43,6 +43,33 @@ public class TransformPositionDifferenceRotation : PropertyModifier /// protected Vector3? previousSourcePosition; + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetFollowOnAxisX(bool value) + { + FollowOnAxis = new Vector3State(value, FollowOnAxis.yState, FollowOnAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetFollowOnAxisY(bool value) + { + FollowOnAxis = new Vector3State(FollowOnAxis.xState, value, FollowOnAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetFollowOnAxisZ(bool value) + { + FollowOnAxis = new Vector3State(FollowOnAxis.xState, FollowOnAxis.yState, value); + } + /// /// Resets the state of the source previous position. /// diff --git a/Runtime/Tracking/Modification/TransformPropertyApplier.cs b/Runtime/Tracking/Modification/TransformPropertyApplier.cs index afba13f0..f2655dd8 100644 --- a/Runtime/Tracking/Modification/TransformPropertyApplier.cs +++ b/Runtime/Tracking/Modification/TransformPropertyApplier.cs @@ -200,6 +200,33 @@ public virtual void SetOffset(TransformData offset) Offset = offset.TryGetGameObject(); } + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetApplyRotationOffsetOnAxisX(bool value) + { + ApplyRotationOffsetOnAxis = new Vector3State(value, ApplyRotationOffsetOnAxis.yState, ApplyRotationOffsetOnAxis.zState); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetApplyRotationOffsetOnAxisY(bool value) + { + ApplyRotationOffsetOnAxis = new Vector3State(ApplyRotationOffsetOnAxis.xState, value, ApplyRotationOffsetOnAxis.zState); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetApplyRotationOffsetOnAxisZ(bool value) + { + ApplyRotationOffsetOnAxis = new Vector3State(ApplyRotationOffsetOnAxis.xState, ApplyRotationOffsetOnAxis.yState, value); + } + /// /// Applies the properties of the parameter to the target. /// diff --git a/Runtime/Tracking/SurfaceLocator.cs b/Runtime/Tracking/SurfaceLocator.cs index 70ff6e8e..1ca561b3 100644 --- a/Runtime/Tracking/SurfaceLocator.cs +++ b/Runtime/Tracking/SurfaceLocator.cs @@ -130,6 +130,33 @@ public class UnityEvent : UnityEvent { } /// protected readonly TransformData transformData = new TransformData(); + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetSearchDirectionX(float value) + { + SearchDirection = new Vector3(value, SearchDirection.y, SearchDirection.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetSearchDirectionY(float value) + { + SearchDirection = new Vector3(SearchDirection.x, value, SearchDirection.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetSearchDirectionZ(float value) + { + SearchDirection = new Vector3(SearchDirection.x, SearchDirection.y, value); + } + /// /// Locates the nearest available surface upon a . /// diff --git a/Runtime/Tracking/Velocity/ArtificialVelocityApplier.cs b/Runtime/Tracking/Velocity/ArtificialVelocityApplier.cs index f3332679..b0ae0a46 100644 --- a/Runtime/Tracking/Velocity/ArtificialVelocityApplier.cs +++ b/Runtime/Tracking/Velocity/ArtificialVelocityApplier.cs @@ -77,6 +77,33 @@ public virtual void Apply() decelerationRoutine = StartCoroutine(BeginDeceleration()); } + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetVelocityX(float value) + { + Velocity = new Vector3(value, Velocity.y, Velocity.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetVelocityY(float value) + { + Velocity = new Vector3(Velocity.x, value, Velocity.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetVelocityZ(float value) + { + Velocity = new Vector3(Velocity.x, Velocity.y, value); + } + /// /// Reset to . /// @@ -85,6 +112,33 @@ public virtual void ClearVelocity() Velocity = Vector3.zero; } + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetAngularVelocityX(float value) + { + AngularVelocity = new Vector3(value, AngularVelocity.y, AngularVelocity.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetAngularVelocityY(float value) + { + AngularVelocity = new Vector3(AngularVelocity.x, value, AngularVelocity.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetAngularVelocityZ(float value) + { + AngularVelocity = new Vector3(AngularVelocity.x, AngularVelocity.y, value); + } + /// /// Reset to . /// diff --git a/Runtime/Tracking/Velocity/VelocityMultiplier.cs b/Runtime/Tracking/Velocity/VelocityMultiplier.cs index 6d13784b..fb191d77 100644 --- a/Runtime/Tracking/Velocity/VelocityMultiplier.cs +++ b/Runtime/Tracking/Velocity/VelocityMultiplier.cs @@ -29,6 +29,60 @@ public class VelocityMultiplier : VelocityTracker [field: DocumentedByXml] public Vector3 AngularVelocityMultiplierFactor { get; set; } = Vector3.one; + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetVelocityMultiplierFactorX(float value) + { + VelocityMultiplierFactor = new Vector3(value, VelocityMultiplierFactor.y, VelocityMultiplierFactor.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetVelocityMultiplierFactorY(float value) + { + VelocityMultiplierFactor = new Vector3(VelocityMultiplierFactor.x, value, VelocityMultiplierFactor.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetVelocityMultiplierFactorZ(float value) + { + VelocityMultiplierFactor = new Vector3(VelocityMultiplierFactor.x, VelocityMultiplierFactor.y, value); + } + + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetAngularVelocityMultiplierFactorX(float value) + { + AngularVelocityMultiplierFactor = new Vector3(value, AngularVelocityMultiplierFactor.y, AngularVelocityMultiplierFactor.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetAngularVelocityMultiplierFactorY(float value) + { + AngularVelocityMultiplierFactor = new Vector3(AngularVelocityMultiplierFactor.x, value, AngularVelocityMultiplierFactor.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetAngularVelocityMultiplierFactorZ(float value) + { + AngularVelocityMultiplierFactor = new Vector3(AngularVelocityMultiplierFactor.x, AngularVelocityMultiplierFactor.y, value); + } + /// public override bool IsActive() { diff --git a/Runtime/Visual/PointsRenderer.cs b/Runtime/Visual/PointsRenderer.cs index 6eab3e72..d02cae53 100644 --- a/Runtime/Visual/PointsRenderer.cs +++ b/Runtime/Visual/PointsRenderer.cs @@ -57,7 +57,7 @@ public class PointsData [field: DocumentedByXml] public bool IsEndPointVisible { get; set; } /// - /// The points along the the most recent cast. + /// The points along the most recent cast. /// [Serialized] [field: DocumentedByXml] @@ -94,6 +94,33 @@ public class PointsData /// protected readonly List segmentClones = new List(); + /// + /// Sets the x value. + /// + /// The value to set to. + public virtual void SetSegmentScaleDirectionX(float value) + { + SegmentScaleDirection = new Vector3(value, SegmentScaleDirection.y, SegmentScaleDirection.z); + } + + /// + /// Sets the y value. + /// + /// The value to set to. + public virtual void SetSegmentScaleDirectionY(float value) + { + SegmentScaleDirection = new Vector3(SegmentScaleDirection.x, value, SegmentScaleDirection.z); + } + + /// + /// Sets the z value. + /// + /// The value to set to. + public virtual void SetSegmentScaleDirectionZ(float value) + { + SegmentScaleDirection = new Vector3(SegmentScaleDirection.x, SegmentScaleDirection.y, value); + } + /// /// Renders the given points. ///