namespace Zinnia.Action { using System; using UnityEngine; using UnityEngine.Events; using Zinnia.Extension; /// /// Emits a value. /// public class FloatAction : Action { /// /// Defines the event with the state. /// [Serializable] public class UnityEvent : UnityEvent { } [Tooltip("The tolerance of equality between two float values.")] [SerializeField] private float equalityTolerance = float.Epsilon; /// /// The tolerance of equality between two values. /// public float EqualityTolerance { get { return equalityTolerance; } set { equalityTolerance = value; if (this.IsMemberChangeAllowed()) { OnAfterEqualityToleranceChange(); } } } /// protected override bool IsValueEqual(float value) { return Value.ApproxEquals(value, EqualityTolerance); } /// protected override bool ShouldActivate(float value) { return !DefaultValue.ApproxEquals(value, EqualityTolerance); } /// /// Called after has been changed. /// protected virtual void OnAfterEqualityToleranceChange() { Receive(Value); } } }