2025-11-09 21:41:39 +00:00
|
|
|
using System;
|
2025-11-06 14:27:44 +01:00
|
|
|
using UnityEngine;
|
2025-11-09 21:41:39 +00:00
|
|
|
using UnityEngine.UI;
|
2025-11-06 17:49:44 +01:00
|
|
|
using Input;
|
|
|
|
|
using AppleHills.Core;
|
2025-11-09 21:41:39 +00:00
|
|
|
using UI.Core;
|
|
|
|
|
using Pixelplacement;
|
|
|
|
|
using Pixelplacement.TweenSystem;
|
2025-11-09 13:23:03 +01:00
|
|
|
using UI;
|
2025-11-06 14:27:44 +01:00
|
|
|
|
2025-11-09 21:41:39 +00:00
|
|
|
public class AppSwitcher : UIPage
|
2025-11-06 14:27:44 +01:00
|
|
|
{
|
2025-11-06 17:49:44 +01:00
|
|
|
public GameObject gameLayoutContainer;
|
|
|
|
|
public GameObject exitButton;
|
2025-11-09 21:41:39 +00:00
|
|
|
public RectMask2D rectMask;
|
|
|
|
|
|
|
|
|
|
[Header("Slide Animation Settings")]
|
|
|
|
|
public float slideDuration = 0.5f;
|
|
|
|
|
|
|
|
|
|
private TweenBase slideInTween;
|
|
|
|
|
private TweenBase slideOutTween;
|
2025-11-06 17:49:44 +01:00
|
|
|
|
2025-11-11 08:48:29 +00:00
|
|
|
internal override void OnManagedAwake()
|
2025-11-06 15:36:02 +01:00
|
|
|
{
|
2025-11-09 21:41:39 +00:00
|
|
|
base.OnManagedAwake();
|
2025-11-11 08:48:29 +00:00
|
|
|
|
2025-11-09 21:41:39 +00:00
|
|
|
PageName = "AppSwitcher";
|
|
|
|
|
|
|
|
|
|
if (rectMask == null)
|
|
|
|
|
{
|
|
|
|
|
rectMask = GetComponent<RectMask2D>();
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-10 15:55:28 +01:00
|
|
|
// Initially hide
|
2025-11-09 21:41:39 +00:00
|
|
|
exitButton.SetActive(false);
|
2025-11-06 15:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-09 21:41:39 +00:00
|
|
|
protected override void DoTransitionIn(Action onComplete)
|
2025-11-06 14:27:44 +01:00
|
|
|
{
|
2025-11-06 17:49:44 +01:00
|
|
|
InputManager.Instance.SetInputMode(InputMode.UI);
|
2025-11-09 21:41:39 +00:00
|
|
|
|
|
|
|
|
gameLayoutContainer.SetActive(true);
|
2025-11-06 17:49:44 +01:00
|
|
|
|
2025-11-09 21:41:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Slide in animation - tween padding.left from 1700 to 0
|
|
|
|
|
slideInTween = TweenPaddingLeft(1700f, 0f, Tween.EaseOut, () =>
|
|
|
|
|
{
|
|
|
|
|
onComplete?.Invoke();
|
|
|
|
|
exitButton.SetActive(true);
|
|
|
|
|
});
|
2025-11-06 17:49:44 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-09 21:41:39 +00:00
|
|
|
protected override void DoTransitionOut(Action onComplete)
|
2025-11-06 17:49:44 +01:00
|
|
|
{
|
2025-11-09 21:41:39 +00:00
|
|
|
|
2025-11-06 17:49:44 +01:00
|
|
|
|
|
|
|
|
// Hide the exit button
|
|
|
|
|
exitButton.SetActive(false);
|
2025-11-09 13:23:03 +01:00
|
|
|
|
2025-11-09 21:41:39 +00:00
|
|
|
// 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);
|
|
|
|
|
});
|
2025-11-06 17:49:44 +01:00
|
|
|
}
|
2025-11-09 21:41:39 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tweens the left padding of the rectMask from startValue to endValue.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private TweenBase TweenPaddingLeft(float startValue, float endValue, AnimationCurve easeCurve, Action onComplete)
|
2025-11-06 17:49:44 +01:00
|
|
|
{
|
2025-11-09 21:41:39 +00:00
|
|
|
// 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
|
|
|
|
|
);
|
2025-11-06 14:27:44 +01:00
|
|
|
}
|
2025-11-06 17:49:44 +01:00
|
|
|
|
2025-11-11 12:32:36 +00:00
|
|
|
internal override void OnManagedDestroy()
|
2025-11-09 21:41:39 +00:00
|
|
|
{
|
|
|
|
|
// Clean up tweens
|
|
|
|
|
slideInTween?.Stop();
|
|
|
|
|
slideOutTween?.Stop();
|
2025-11-06 17:49:44 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-06 14:27:44 +01:00
|
|
|
}
|