using UnityEngine; using UnityEngine.Events; namespace DuloGames.UI.Tweens { public struct Vector3Tween : ITweenValue { public class Vector3TweenCallback : UnityEvent {} public class Vector3TweenFinishCallback : UnityEvent {} private Vector3 m_StartVector3; private Vector3 m_TargetVector3; private float m_Duration; private bool m_IgnoreTimeScale; private TweenEasing m_Easing; private Vector3TweenCallback m_Target; private Vector3TweenFinishCallback m_Finish; /// /// Gets or sets the starting Vector3. /// /// The start color. public Vector3 startVector3 { get { return m_StartVector3; } set { m_StartVector3 = value; } } /// /// Gets or sets the target Vector3. /// /// The color of the target. public Vector3 targetVector3 { get { return m_TargetVector3; } set { m_TargetVector3 = value; } } /// /// Gets or sets the duration of the tween. /// /// The duration. public float duration { get { return m_Duration; } set { m_Duration = value; } } /// /// Gets or sets a value indicating whether this should ignore time scale. /// /// true if ignore time scale; otherwise, false. public bool ignoreTimeScale { get { return m_IgnoreTimeScale; } set { m_IgnoreTimeScale = value; } } /// /// Gets or sets the tween easing. /// /// The easing. public TweenEasing easing { get { return m_Easing; } set { m_Easing = value; } } /// /// Tweens the color based on percentage. /// /// Float percentage. public void TweenValue(float floatPercentage) { if (!this.ValidTarget()) return; this.m_Target.Invoke( Vector3.Lerp (this.m_StartVector3, this.m_TargetVector3, floatPercentage) ); } /// /// Adds a on changed callback. /// /// Callback. public void AddOnChangedCallback(UnityAction callback) { if (m_Target == null) m_Target = new Vector3TweenCallback(); m_Target.AddListener(callback); } /// /// Adds a on finish callback. /// /// Callback. public void AddOnFinishCallback(UnityAction callback) { if (m_Finish == null) m_Finish = new Vector3TweenFinishCallback(); m_Finish.AddListener(callback); } public bool GetIgnoreTimescale() { return m_IgnoreTimeScale; } public float GetDuration() { return m_Duration; } public bool ValidTarget() { return m_Target != null; } /// /// Invokes the on finish callback. /// public void Finished() { if (m_Finish != null) m_Finish.Invoke(); } } }