using UnityEngine; using System.Collections.Generic; namespace Lean.Transition.Method { /// This component calls the RectTransform.SetAsLastSibling method when this transition completes. [HelpURL(LeanTransition.HelpUrlPrefix + "LeanRectTransformSetAsLastSibling")] [AddComponentMenu(LeanTransition.MethodsMenuPrefix + "RectTransform/RectTransform.SetAsLastSibling" + LeanTransition.MethodsMenuSuffix + "(LeanRectTransformSetAsLastSibling)")] public class LeanRectTransformSetAsLastSibling : LeanMethodWithStateAndTarget { public override System.Type GetTargetType() { return typeof(RectTransform); } public override void Register() { PreviousState = Register(GetAliasedTarget(Data.Target), Data.Duration); } public static LeanState Register(RectTransform target, float duration) { var state = LeanTransition.SpawnWithTarget(State.Pool, target); return LeanTransition.Register(state, duration); } [System.Serializable] public class State : LeanStateWithTarget { public override void UpdateWithTarget(float progress) { if (progress == 1.0f) { Target.SetAsLastSibling(); } } public static Stack Pool = new Stack(); public override void Despawn() { Pool.Push(this); } } public State Data; } }