using System; using UnityEngine; using UnityEngine.UI; using Input; using AppleHills.Core; using UI.Core; using Pixelplacement; using Pixelplacement.TweenSystem; using UI; public class AppSwitcher : UIPage { public GameObject gameLayoutContainer; public GameObject exitButton; public RectMask2D rectMask; [Header("Slide Animation Settings")] public float slideDuration = 0.5f; private TweenBase slideInTween; private TweenBase slideOutTween; protected override void OnManagedAwake() { base.OnManagedAwake(); PageName = "AppSwitcher"; if (rectMask == null) { rectMask = GetComponent(); } // Initially hide exitButton.SetActive(false); } protected override void DoTransitionIn(Action onComplete) { InputManager.Instance.SetInputMode(InputMode.UI); gameLayoutContainer.SetActive(true); // Slide in animation - tween padding.left from 1700 to 0 slideInTween = TweenPaddingLeft(1700f, 0f, Tween.EaseOut, () => { onComplete?.Invoke(); exitButton.SetActive(true); }); } protected override void DoTransitionOut(Action onComplete) { // Hide the exit button exitButton.SetActive(false); // Slide out animation - tween padding.left from 0 to 1700 slideOutTween = TweenPaddingLeft(0f, 1700f, Tween.EaseIn, () => { gameLayoutContainer.SetActive(false); onComplete?.Invoke(); InputManager.Instance.SetInputMode(InputMode.GameAndUI); }); } /// /// Tweens the left padding of the rectMask from startValue to endValue. /// private TweenBase TweenPaddingLeft(float startValue, float endValue, AnimationCurve easeCurve, Action onComplete) { // Set starting position Vector4 startPadding = rectMask.padding; startPadding.x = startValue; rectMask.padding = startPadding; return Tween.Value( startValue, endValue, (value) => { Vector4 padding = rectMask.padding; padding.x = value; rectMask.padding = padding; }, slideDuration, 0f, // no delay easeCurve, Tween.LoopType.None, null, // onStart onComplete ); } protected override void OnDestroy() { base.OnDestroy(); // Clean up tweens slideInTween?.Stop(); slideOutTween?.Stop(); } }