超大量的更新 修复很多问题,gameplay特效初步

This commit is contained in:
FloatGaming
2026-02-14 23:46:20 +08:00
parent ef8eb67259
commit 3a7a0b4669
360 changed files with 85670 additions and 4144 deletions
@@ -0,0 +1,441 @@
using System.Collections;
using DG.Tweening;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class UI_CharacterDialogController : MonoBehaviour
{
[SerializeField] private string requiredSceneName = "UI_UI";
[SerializeField] private string characterObjectName = "Image_Character";
[SerializeField] private string dialogObjectName = "UI_DIALOG";
[Header("Enter")]
[SerializeField] private float enterDuration = 0.3f;
[SerializeField] private float enterFromOffsetY = 60f;
[SerializeField] private Ease enterEase = Ease.OutCubic;
[Header("Blink Out")]
[SerializeField] private int blinkCount = 2;
[SerializeField] private float blinkHalfTime = 0.05f;
[Header("Auto Hide")]
[SerializeField] private float idleHideDelay = 5f;
[SerializeField] private bool useUnscaledTime = true;
private RectTransform dialogRect;
private CanvasGroup dialogGroup;
private Vector2 dialogBasePos;
private bool basePosCached;
private RectTransform boundCharacterRect;
private int bindAttemptToken;
private bool isVisible;
private Coroutine idleRoutine;
private Coroutine bindRoutine;
private Coroutine keepAliveRoutine;
private Sequence dialogSequence;
private UI_CharacterDialogClickProxy clickProxy;
private Button characterButton;
private bool initialHideDone;
private void OnEnable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.activeSceneChanged -= OnActiveSceneChanged;
SceneManager.activeSceneChanged += OnActiveSceneChanged;
RebindSoon();
if (keepAliveRoutine == null)
keepAliveRoutine = StartCoroutine(KeepBindingAliveRoutine());
}
private void OnDisable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.activeSceneChanged -= OnActiveSceneChanged;
KillTweens();
if (characterButton != null)
{
characterButton.onClick.RemoveListener(OnCharacterClicked);
characterButton = null;
}
if (idleRoutine != null)
{
StopCoroutine(idleRoutine);
idleRoutine = null;
}
if (bindRoutine != null)
{
StopCoroutine(bindRoutine);
bindRoutine = null;
}
if (keepAliveRoutine != null)
{
StopCoroutine(keepAliveRoutine);
keepAliveRoutine = null;
}
clickProxy = null;
dialogRect = null;
dialogGroup = null;
boundCharacterRect = null;
basePosCached = false;
initialHideDone = false;
}
public void RebindSoon()
{
bindAttemptToken++;
if (bindRoutine != null)
StopCoroutine(bindRoutine);
bindRoutine = StartCoroutine(BindRoutine(bindAttemptToken));
}
private IEnumerator BindRoutine(int token)
{
yield return null;
TryBind();
yield return null;
if (token != bindAttemptToken)
yield break;
yield return null;
TryBind();
if (token != bindAttemptToken)
yield break;
yield return null;
TryBind();
if (token != bindAttemptToken)
yield break;
yield return new WaitForSecondsRealtime(0.2f);
TryBind();
if (token != bindAttemptToken)
yield break;
yield return new WaitForSecondsRealtime(0.6f);
TryBind();
bindRoutine = null;
}
private void TryBind()
{
if (!IsAllowedScene())
return;
Scene scene = gameObject.scene;
if (!scene.IsValid() || !scene.isLoaded)
scene = SceneManager.GetActiveScene();
Transform dialogTr = FindInSceneByName(scene, dialogObjectName);
if (dialogTr == null)
dialogTr = FindInSceneByName(SceneManager.GetActiveScene(), dialogObjectName);
if (dialogTr != null)
{
RectTransform nextDialogRect = dialogTr as RectTransform;
bool dialogChanged = dialogRect != nextDialogRect;
dialogRect = nextDialogRect;
if (dialogRect != null)
{
dialogGroup = dialogRect.GetComponent<CanvasGroup>();
if (dialogGroup == null)
dialogGroup = dialogRect.gameObject.AddComponent<CanvasGroup>();
if (dialogChanged || !basePosCached)
{
dialogBasePos = dialogRect.anchoredPosition;
basePosCached = true;
}
}
if (!initialHideDone)
{
HideImmediate();
initialHideDone = true;
}
}
Transform characterTr = FindInSceneByName(scene, characterObjectName);
if (characterTr == null)
characterTr = FindInSceneByName(SceneManager.GetActiveScene(), characterObjectName);
if (characterTr != null)
{
boundCharacterRect = characterTr as RectTransform;
clickProxy = characterTr.GetComponent<UI_CharacterDialogClickProxy>();
if (clickProxy == null)
clickProxy = characterTr.gameObject.AddComponent<UI_CharacterDialogClickProxy>();
clickProxy.Bind(this);
// Ensure the image can receive click events.
Graphic graphic = characterTr.GetComponent<Graphic>();
if (graphic != null)
graphic.raycastTarget = true;
// Also bind through Button click to avoid missing pointer callbacks.
Button btn = characterTr.GetComponent<Button>();
if (btn == null)
{
btn = characterTr.gameObject.AddComponent<Button>();
btn.transition = Selectable.Transition.None;
if (graphic != null)
btn.targetGraphic = graphic;
}
if (characterButton != null && characterButton != btn)
characterButton.onClick.RemoveListener(OnCharacterClicked);
characterButton = btn;
characterButton.onClick.RemoveListener(OnCharacterClicked);
characterButton.onClick.AddListener(OnCharacterClicked);
}
else
{
boundCharacterRect = null;
}
}
public void OnCharacterClicked()
{
if (!IsBindingValid())
TryBind();
if (dialogRect == null || dialogGroup == null || !basePosCached)
return;
if (isVisible)
{
BlinkOut(() => PlayEnter(), deactivateAtEnd: true);
}
else
{
PlayEnter();
}
}
private void PlayEnter()
{
if (dialogRect == null || dialogGroup == null)
return;
KillTweens();
dialogRect.gameObject.SetActive(true);
dialogRect.anchoredPosition = dialogBasePos - new Vector2(0f, Mathf.Abs(enterFromOffsetY));
dialogGroup.alpha = 0f;
dialogSequence = DOTween.Sequence().SetUpdate(useUnscaledTime);
dialogSequence.Join(dialogRect.DOAnchorPos(dialogBasePos, Mathf.Max(0.01f, enterDuration)).SetEase(enterEase));
dialogSequence.Join(dialogGroup.DOFade(1f, Mathf.Max(0.01f, enterDuration)).SetEase(Ease.OutCubic));
dialogSequence.OnComplete(() => dialogSequence = null);
isVisible = true;
RestartIdleTimer();
}
private void BlinkOut(System.Action onComplete, bool deactivateAtEnd)
{
if (dialogRect == null || dialogGroup == null)
{
onComplete?.Invoke();
return;
}
KillTweens();
dialogRect.gameObject.SetActive(true);
dialogSequence = DOTween.Sequence().SetUpdate(useUnscaledTime);
int blinks = Mathf.Max(1, blinkCount);
float half = Mathf.Max(0.01f, blinkHalfTime);
for (int i = 0; i < blinks; i++)
{
dialogSequence.Append(dialogGroup.DOFade(0f, half).SetEase(Ease.OutQuad));
dialogSequence.Append(dialogGroup.DOFade(1f, half).SetEase(Ease.OutQuad));
}
dialogSequence.Append(dialogGroup.DOFade(0f, half).SetEase(Ease.OutQuad));
dialogSequence.OnComplete(() =>
{
dialogSequence = null;
isVisible = false;
if (deactivateAtEnd && dialogRect != null)
dialogRect.gameObject.SetActive(false);
onComplete?.Invoke();
});
}
private void RestartIdleTimer()
{
if (idleRoutine != null)
StopCoroutine(idleRoutine);
idleRoutine = StartCoroutine(IdleHideRoutine());
}
private IEnumerator IdleHideRoutine()
{
float delay = Mathf.Max(0.2f, idleHideDelay);
float t = 0f;
while (t < delay)
{
t += useUnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime;
yield return null;
}
if (isVisible)
{
BlinkOut(onComplete: null, deactivateAtEnd: true);
}
idleRoutine = null;
}
private void HideImmediate()
{
if (dialogRect == null || dialogGroup == null)
return;
KillTweens();
dialogGroup.alpha = 0f;
dialogRect.anchoredPosition = dialogBasePos;
dialogRect.gameObject.SetActive(false);
isVisible = false;
}
private void KillTweens()
{
if (dialogSequence != null)
{
dialogSequence.Kill();
dialogSequence = null;
}
if (dialogRect != null)
dialogRect.DOKill();
if (dialogGroup != null)
dialogGroup.DOKill();
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (string.Equals(scene.name, requiredSceneName, System.StringComparison.OrdinalIgnoreCase))
RebindSoon();
}
private void OnActiveSceneChanged(Scene from, Scene to)
{
if (string.Equals(to.name, requiredSceneName, System.StringComparison.OrdinalIgnoreCase))
RebindSoon();
}
private IEnumerator KeepBindingAliveRoutine()
{
while (enabled)
{
if (IsAllowedScene() && !IsBindingValid())
RebindSoon();
yield return new WaitForSecondsRealtime(0.5f);
}
}
private bool IsBindingValid()
{
if (!IsAllowedScene())
return false;
if (dialogRect == null || dialogGroup == null || !basePosCached)
return false;
if (boundCharacterRect == null)
return false;
if (characterButton == null)
return false;
return true;
}
private bool IsAllowedScene()
{
if (string.IsNullOrEmpty(requiredSceneName))
return true;
Scene own = gameObject.scene;
if (own.IsValid() && string.Equals(own.name, requiredSceneName, System.StringComparison.OrdinalIgnoreCase))
return true;
Scene active = SceneManager.GetActiveScene();
return active.IsValid() && string.Equals(active.name, requiredSceneName, System.StringComparison.OrdinalIgnoreCase);
}
private Transform FindInSceneByName(Scene scene, string objectName)
{
if (!scene.IsValid() || !scene.isLoaded || string.IsNullOrEmpty(objectName))
return null;
Transform[] all = UnityEngine.Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
for (int i = 0; i < all.Length; i++)
{
Transform t = all[i];
if (t == null || t.gameObject.scene != scene)
continue;
if (string.Equals(t.name, objectName, System.StringComparison.OrdinalIgnoreCase))
return t;
}
return null;
}
}
public class UI_CharacterDialogClickProxy : MonoBehaviour, IPointerClickHandler
{
private UI_CharacterDialogController controller;
public void Bind(UI_CharacterDialogController owner)
{
controller = owner;
}
public void OnPointerClick(PointerEventData eventData)
{
controller?.OnCharacterClicked();
}
}
static class UI_CharacterDialogControllerBootstrap
{
private const string SceneName = "UI_UI";
private const string HostName = "__UICharacterDialogControllerHost";
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Init()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneLoaded += OnSceneLoaded;
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (!string.Equals(scene.name, SceneName, System.StringComparison.OrdinalIgnoreCase))
return;
GameObject host = FindHostInScene(scene, HostName);
if (host == null)
{
host = new GameObject(HostName);
SceneManager.MoveGameObjectToScene(host, scene);
}
UI_CharacterDialogController controller = host.GetComponent<UI_CharacterDialogController>();
if (controller == null)
controller = host.AddComponent<UI_CharacterDialogController>();
controller.RebindSoon();
}
private static GameObject FindHostInScene(Scene scene, string hostName)
{
if (!scene.IsValid() || !scene.isLoaded)
return null;
Transform[] all = UnityEngine.Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
for (int i = 0; i < all.Length; i++)
{
Transform t = all[i];
if (t == null || t.gameObject.scene != scene)
continue;
if (t.name == hostName)
return t.gameObject;
}
return null;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 51eb8dcab528ffb46855652bbb8c71e9
@@ -37,7 +37,7 @@ class UI_Panel_Character : MonoBehaviour
}
else if(canvasGroup == null)
{
//Debug.LogError("Error for getting canvas group");
// Documentation text normalized.
return;
}
@@ -118,4 +118,4 @@ class UI_Panel_Character : MonoBehaviour
yield return null;
}
}
}
}
+107 -65
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -274,8 +274,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
var so = Instantiate(item);
data_List.Add(so);
// 每处理 5 个数据等待一帧,防止主线程卡死
if (i > 0 && i % 5 == 0)
// Documentation text normalized.
{
yield return null;
}
@@ -324,6 +323,13 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
{
return false;
}
if (panel == ui_Panel_Setting)
{
UI_SettingsPanelEnterAnim enterAnim = panel.GetComponent<UI_SettingsPanelEnterAnim>();
if (enterAnim == null)
enterAnim = panel.AddComponent<UI_SettingsPanelEnterAnim>();
enterAnim.enabled = true;
}
panel.SetActive(true);
return true;
}
@@ -334,7 +340,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
return;
}
selectScene_Loading = true;
// 使用异步加载场景,防止 GUI 冻结
// Documentation text normalized.
StartCoroutine(LoadSelectSceneAsync());
}
@@ -342,7 +348,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(ui_Select_Music_Scene_Name, LoadSceneMode.Single);
// 等待加载完成
// Documentation text normalized.
while (!asyncLoad.isDone)
{
yield return null;
@@ -362,6 +368,8 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
Setup_RightButtons_Hover();
Setup_Jiantou_Hover();
Fix_Button_Raycast();
Ensure_Character_Dialog_Controller();
StartCoroutine(Ensure_Character_Dialog_Controller_Delayed());
if (play_Enter_OnEnable)
{
Start_Enter_Routine();
@@ -371,6 +379,55 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
Start_Jiantou_Loop();
}
}
IEnumerator Ensure_Character_Dialog_Controller_Delayed()
{
yield return null;
Ensure_Character_Dialog_Controller();
yield return null;
Ensure_Character_Dialog_Controller();
}
void Ensure_Character_Dialog_Controller()
{
Scene scene = SceneManager.GetActiveScene();
if (!scene.IsValid() || !string.Equals(scene.name, "UI_UI", StringComparison.OrdinalIgnoreCase))
{
return;
}
GameObject host = null;
Transform[] all = UnityEngine.Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
for (int i = 0; i < all.Length; i++)
{
Transform t = all[i];
if (t == null || t.gameObject.scene != scene)
{
continue;
}
if (string.Equals(t.name, "__UICharacterDialogControllerHost", StringComparison.Ordinal))
{
host = t.gameObject;
break;
}
}
if (host == null)
{
host = new GameObject("__UICharacterDialogControllerHost");
try { SceneManager.MoveGameObjectToScene(host, scene); } catch { }
}
UI_CharacterDialogController controller = host.GetComponent<UI_CharacterDialogController>();
if (controller == null)
{
controller = host.AddComponent<UI_CharacterDialogController>();
}
if (!controller.enabled)
{
controller.enabled = true;
}
controller.RebindSoon();
}
void Fix_Button_Raycast()
{
if (!fix_Button_Raycast)
@@ -3234,15 +3291,17 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
float textFlashInterval = 0.02f;
RectTransform imageRect;
Vector2 imageBasePos;
CanvasGroup imageGroup;
readonly List<CanvasGroup> textGroups = new();
Tween imageTween;
readonly List<Tween> textTweens = new();
public void ApplyConfig(float idleOffsetValue, float finalOffsetValue, float moveTimeValue, Ease moveEaseValue,
float textFlashTimeValue, int textFlashCountValue, float textFlashIntervalValue)
{
idleOffset = Mathf.Max(0f, idleOffsetValue);
finalOffset = finalOffsetValue;
// Keep icon inside the button frame: positive config means "shift left by this amount".
// Use a softened offset so icon sits slightly more to the right.
finalOffset = -Mathf.Abs(finalOffsetValue) * 0.75f;
moveTime = Mathf.Max(0.01f, moveTimeValue);
moveEase = moveEaseValue;
textFlashTime = Mathf.Max(0.01f, textFlashTimeValue);
@@ -3276,6 +3335,12 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
if (imageRect != null)
{
imageBasePos = imageRect.anchoredPosition;
if (imageGroup == null)
{
imageGroup = imageRect.GetComponent<CanvasGroup>();
if (imageGroup == null)
imageGroup = imageRect.gameObject.AddComponent<CanvasGroup>();
}
}
textGroups.Clear();
for (int i = 0; i < transform.childCount; i++)
@@ -3318,32 +3383,36 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
{
if (imageRect != null)
{
imageRect.anchoredPosition = imageBasePos + Vector2.left * idleOffset;
// Keep icon at its final position; only toggle visibility on hover.
imageRect.anchoredPosition = imageBasePos + Vector2.right * finalOffset;
}
if (imageGroup != null)
{
imageGroup.alpha = 0f; // hidden until hover
}
for (int i = 0; i < textGroups.Count; i++)
{
if (textGroups[i] != null)
{
textGroups[i].alpha = 0f;
// Text should always be visible (no flash-in).
textGroups[i].alpha = 1f;
}
}
}
public void OnPointerEnter(PointerEventData eventData)
{
MoveImage(true);
FlashTexts();
FlashImage();
}
public void OnPointerExit(PointerEventData eventData)
{
MoveImage(false);
HideTexts();
HideImage();
}
void MoveImage(bool toFinal)
void FlashImage()
{
if (imageRect == null)
if (imageRect == null || imageGroup == null)
{
return;
}
@@ -3352,69 +3421,42 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
imageTween.Kill();
imageTween = null;
}
Vector2 target = toFinal
? imageBasePos + Vector2.right * finalOffset
: imageBasePos + Vector2.left * idleOffset;
imageTween = imageRect.DOAnchorPos(target, moveTime)
.SetEase(moveEase)
.SetUpdate(true);
}
void FlashTexts()
{
HideTexts();
for (int i = 0; i < textGroups.Count; i++)
{
CanvasGroup group = textGroups[i];
if (group == null)
{
continue;
}
group.alpha = 0f;
Sequence seq = DOTween.Sequence().SetUpdate(true);
for (int c = 0; c < textFlashCount; c++)
{
seq.Append(group.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
seq.Append(group.DOFade(0f, textFlashTime).SetEase(Ease.InQuad));
if (textFlashInterval > 0f)
{
seq.AppendInterval(textFlashInterval);
}
}
seq.Append(group.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
textTweens.Add(seq);
}
}
// Ensure icon is at its final position (no translation anim).
imageRect.anchoredPosition = imageBasePos + Vector2.right * finalOffset;
void HideTexts()
{
for (int i = 0; i < textTweens.Count; i++)
// Flash-in (blink) on hover, then stay visible.
imageGroup.alpha = 0f;
Sequence seq = DOTween.Sequence().SetUpdate(true);
for (int c = 0; c < textFlashCount; c++)
{
Tween tween = textTweens[i];
if (tween != null)
seq.Append(imageGroup.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
seq.Append(imageGroup.DOFade(0f, textFlashTime).SetEase(Ease.InQuad));
if (textFlashInterval > 0f)
{
tween.Kill();
}
}
textTweens.Clear();
for (int i = 0; i < textGroups.Count; i++)
{
CanvasGroup group = textGroups[i];
if (group != null)
{
group.alpha = 0f;
seq.AppendInterval(textFlashInterval);
}
}
seq.Append(imageGroup.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
imageTween = seq;
}
void KillTweens()
void HideImage()
{
if (imageTween != null)
{
imageTween.Kill();
imageTween = null;
}
HideTexts();
if (imageGroup != null)
{
imageGroup.alpha = 0f;
}
}
void KillTweens()
{
HideImage();
}
}
@@ -3603,7 +3645,7 @@ public class UI_StartButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
char[] filler = new char[remain];
for (int r = 0; r < remain; r++)
{
filler[r] = useDot ? '·' : randomChars[(i + r) % randomChars.Length];
filler[r] = useDot ? '' : randomChars[(i + r) % randomChars.Length];
}
suffix = new string(filler);
}
+101 -1
View File
@@ -1,5 +1,7 @@
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using System.Collections.Generic;
public class ui_Panel_Setting : MonoBehaviour
{
@@ -10,6 +12,19 @@ public class ui_Panel_Setting : MonoBehaviour
[SerializeField] Toggle toggle_View;
[SerializeField] Toggle toggle_View_Pie;
[SerializeField] GameObject view_Content;
[Header("Enter Animation")]
[SerializeField] bool playEnterAnimation = true;
[SerializeField] float enterItemDuration = 0.24f;
[SerializeField] float enterItemStagger = 0.03f;
[SerializeField] float enterOffsetY = 28f;
[SerializeField] Ease enterEase = Ease.OutCubic;
private readonly List<RectTransform> enterItems = new List<RectTransform>();
private readonly List<CanvasGroup> enterGroups = new List<CanvasGroup>();
private readonly List<Vector2> enterBasePos = new List<Vector2>();
private Sequence enterSequence;
private void Awake()
{
button_Close?.onClick.AddListener(Close);
@@ -36,6 +51,20 @@ public class ui_Panel_Setting : MonoBehaviour
toggle_Game.isOn = true;
}
private void OnEnable()
{
if (playEnterAnimation)
{
PlayEnterAnimation();
}
}
private void OnDisable()
{
KillEnterAnimation();
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
@@ -43,8 +72,79 @@ public class ui_Panel_Setting : MonoBehaviour
Close();
}
}
private void PlayEnterAnimation()
{
KillEnterAnimation();
CacheEnterItems();
if (enterItems.Count == 0)
return;
enterSequence = DOTween.Sequence().SetUpdate(true);
for (int i = 0; i < enterItems.Count; i++)
{
RectTransform rt = enterItems[i];
CanvasGroup cg = enterGroups[i];
Vector2 basePos = enterBasePos[i];
if (rt == null || cg == null)
continue;
rt.DOKill();
cg.DOKill();
rt.anchoredPosition = basePos - new Vector2(0f, Mathf.Abs(enterOffsetY));
cg.alpha = 0f;
float start = i * Mathf.Max(0f, enterItemStagger);
enterSequence.Insert(start,
rt.DOAnchorPos(basePos, Mathf.Max(0.01f, enterItemDuration))
.SetEase(enterEase)
.SetUpdate(true));
enterSequence.Insert(start,
cg.DOFade(1f, Mathf.Max(0.01f, enterItemDuration))
.SetEase(Ease.OutCubic)
.SetUpdate(true));
}
}
private void CacheEnterItems()
{
enterItems.Clear();
enterGroups.Clear();
enterBasePos.Clear();
for (int i = 0; i < transform.childCount; i++)
{
Transform child = transform.GetChild(i);
if (child == null || !child.gameObject.activeInHierarchy)
continue;
RectTransform rt = child as RectTransform;
if (rt == null)
continue;
CanvasGroup cg = rt.GetComponent<CanvasGroup>();
if (cg == null)
cg = rt.gameObject.AddComponent<CanvasGroup>();
enterItems.Add(rt);
enterGroups.Add(cg);
enterBasePos.Add(rt.anchoredPosition);
}
}
private void KillEnterAnimation()
{
if (enterSequence != null)
{
enterSequence.Kill();
enterSequence = null;
}
}
void Close()
{
gameObject.SetActive(false);
}
}
}
@@ -0,0 +1,116 @@
using DG.Tweening;
using UnityEngine;
[DisallowMultipleComponent]
public class UI_SettingsPanelEnterAnim : MonoBehaviour
{
[SerializeField] private RectTransform moveTarget;
[SerializeField] private CanvasGroup fadeTarget;
[SerializeField] private bool playOnEnable = true;
[SerializeField] private float enterDuration = 0.3f;
[SerializeField] private float fromOffsetY = 32f;
[SerializeField] private Ease enterEase = Ease.OutCubic;
[SerializeField] private bool useUnscaledTime = true;
private Sequence enterSequence;
private bool basePosCached;
private Vector2 basePos;
private void Awake()
{
AutoWire();
CacheBasePos();
}
private void OnEnable()
{
if (playOnEnable)
Play();
}
private void OnDisable()
{
KillTween();
ResetToBase();
}
public void Play()
{
AutoWire();
CacheBasePos();
if (moveTarget == null || fadeTarget == null)
return;
KillTween();
moveTarget.anchoredPosition = basePos - new Vector2(0f, Mathf.Abs(fromOffsetY));
fadeTarget.alpha = 0f;
fadeTarget.interactable = false;
fadeTarget.blocksRaycasts = false;
enterSequence = DOTween.Sequence().SetUpdate(useUnscaledTime);
enterSequence.Join(moveTarget.DOAnchorPos(basePos, Mathf.Max(0.01f, enterDuration)).SetEase(enterEase));
enterSequence.Join(fadeTarget.DOFade(1f, Mathf.Max(0.01f, enterDuration)).SetEase(Ease.OutCubic));
enterSequence.OnComplete(() =>
{
fadeTarget.interactable = true;
fadeTarget.blocksRaycasts = true;
enterSequence = null;
});
}
private void AutoWire()
{
if (moveTarget == null)
{
moveTarget = transform as RectTransform;
if (moveTarget == null)
moveTarget = GetComponentInChildren<RectTransform>(true);
}
if (fadeTarget == null)
fadeTarget = GetComponent<CanvasGroup>();
if (fadeTarget == null)
fadeTarget = gameObject.AddComponent<CanvasGroup>();
}
private void CacheBasePos()
{
if (moveTarget == null)
return;
if (!basePosCached)
{
basePos = moveTarget.anchoredPosition;
basePosCached = true;
}
}
private void ResetToBase()
{
if (moveTarget != null && basePosCached)
moveTarget.anchoredPosition = basePos;
if (fadeTarget != null)
{
fadeTarget.alpha = 1f;
fadeTarget.interactable = true;
fadeTarget.blocksRaycasts = true;
}
}
private void KillTween()
{
if (enterSequence != null)
{
enterSequence.Kill();
enterSequence = null;
}
if (moveTarget != null)
moveTarget.DOKill();
if (fadeTarget != null)
fadeTarget.DOKill();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 128b12802ff1c684abfc7da39a0deb5c
@@ -313,6 +313,127 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &698142945755259558
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 664855366139876558}
- component: {fileID: 6815741791543722666}
- component: {fileID: 1445541171937349538}
- component: {fileID: 1221776354986423673}
m_Layer: 0
m_Name: back
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &664855366139876558
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 698142945755259558}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8436329948899178167}
m_Father: {fileID: 4201371652593379150}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 97, y: 97}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6815741791543722666
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 698142945755259558}
m_CullTransparentMesh: 1
--- !u!114 &1445541171937349538
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 698142945755259558}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 6349329690924382296, guid: ff06dc687af02f74c8fbd98368463fc2, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &1221776354986423673
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 698142945755259558}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1445541171937349538}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &794346939895717571
GameObject:
m_ObjectHideFlags: 0
@@ -829,6 +950,7 @@ RectTransform:
- {fileID: 1216734273723155318}
- {fileID: 4507029859229390628}
- {fileID: 3166511394318740470}
- {fileID: 4201371652593379150}
m_Father: {fileID: 4008714089197239054}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
@@ -1702,6 +1824,81 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1883765842619825806
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8344488991073226701}
- component: {fileID: 8707209540160881515}
- component: {fileID: 3843922392991303629}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8344488991073226701
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1883765842619825806}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5977557715898357349}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.6977236, y: 0.32699218}
m_AnchorMax: {x: 0.6977236, y: 0.32699218}
m_AnchoredPosition: {x: -19.179, y: 16.782}
m_SizeDelta: {x: 53.555, y: 53.5554}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8707209540160881515
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1883765842619825806}
m_CullTransparentMesh: 1
--- !u!114 &3843922392991303629
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1883765842619825806}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: d0ef0c9be447e1f4296eb8a4b9195c8c, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1934290382038477745
GameObject:
m_ObjectHideFlags: 0
@@ -1777,6 +1974,71 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &2123526779575187879
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4201371652593379150}
- component: {fileID: 4595481187193100221}
m_Layer: 0
m_Name: New back
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4201371652593379150
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2123526779575187879}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 5.504588}
m_LocalScale: {x: 0.51, y: 0.51, z: 0.51}
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 6419923115795927302}
- {fileID: 664855366139876558}
- {fileID: 5977557715898357349}
m_Father: {fileID: 5634981615641515618}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -329.2, y: 0.00002670288}
m_SizeDelta: {x: 2410.4807, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4595481187193100221
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2123526779575187879}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: -2040.77
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &2157369845151287564
GameObject:
m_ObjectHideFlags: 0
@@ -2238,6 +2500,127 @@ RectTransform:
m_AnchoredPosition: {x: -675.6, y: -0.00005340576}
m_SizeDelta: {x: 128, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2496832619426805493
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5977557715898357349}
- component: {fileID: 7995155685421482441}
- component: {fileID: 3428519051158734592}
- component: {fileID: 4088529162781090059}
m_Layer: 0
m_Name: home
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5977557715898357349
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2496832619426805493}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8344488991073226701}
m_Father: {fileID: 4201371652593379150}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 97, y: 97}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7995155685421482441
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2496832619426805493}
m_CullTransparentMesh: 1
--- !u!114 &3428519051158734592
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2496832619426805493}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 6349329690924382296, guid: ff06dc687af02f74c8fbd98368463fc2, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &4088529162781090059
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2496832619426805493}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 3428519051158734592}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &2529537244873479850
GameObject:
m_ObjectHideFlags: 0
@@ -4040,6 +4423,11 @@ MonoBehaviour:
userInfo_prefab: {fileID: 0}
email_prefab: {fileID: 3756075665884320709, guid: 41f4ea31b64f18d48aeef21b79930a6c, type: 3}
notice_prefab: {fileID: 8527835049849151044, guid: 06bb6d3a45697374ab4f5ff36356d138, type: 3}
back_navButton: {fileID: 0}
home_navButton: {fileID: 0}
settings_navButton: {fileID: 0}
homeSceneName: UI_UI
backFallbackSceneName: Main_main
--- !u!114 &2510911207525280717
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -4436,6 +4824,85 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5455887339197002951
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 94861546549908736}
- component: {fileID: 185682819927651411}
- component: {fileID: 8311074806369947263}
m_Layer: 0
m_Name: Text (Legacy)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &94861546549908736
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5455887339197002951}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6419923115795927302}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 7.1215, y: -0.0335}
m_SizeDelta: {x: 56.838, y: 58.3341}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &185682819927651411
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5455887339197002951}
m_CullTransparentMesh: 1
--- !u!114 &8311074806369947263
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5455887339197002951}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: cc180dff846d13a4d88ddaed6f77e5cd, type: 3}
m_FontSize: 44
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 44
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\uFF1F"
--- !u!1 &5745207992015071035
GameObject:
m_ObjectHideFlags: 0
@@ -5469,6 +5936,128 @@ MonoBehaviour:
m_Spacing: {x: 20, y: 20}
m_Constraint: 1
m_ConstraintCount: 4
--- !u!1 &7302066207285333480
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6419923115795927302}
- component: {fileID: 1613315426306319868}
- component: {fileID: 510332109012089948}
- component: {fileID: 6945238783669072533}
m_Layer: 0
m_Name: question
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6419923115795927302
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7302066207285333480}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4789218457072247502}
- {fileID: 94861546549908736}
m_Father: {fileID: 4201371652593379150}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 97, y: 97}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1613315426306319868
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7302066207285333480}
m_CullTransparentMesh: 1
--- !u!114 &510332109012089948
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7302066207285333480}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 6349329690924382296, guid: ff06dc687af02f74c8fbd98368463fc2, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &6945238783669072533
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7302066207285333480}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 510332109012089948}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &7324940213527366140
GameObject:
m_ObjectHideFlags: 0
@@ -6128,7 +6717,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &2726789671155220641
RectTransform:
m_ObjectHideFlags: 0
@@ -6345,6 +6934,81 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &8339357190892337068
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8436329948899178167}
- component: {fileID: 4450874966179245808}
- component: {fileID: 6474466730584838898}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8436329948899178167
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8339357190892337068}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 664855366139876558}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -0.0000038147, y: 0.000049591}
m_SizeDelta: {x: 36.928, y: 36.928}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4450874966179245808
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8339357190892337068}
m_CullTransparentMesh: 1
--- !u!114 &6474466730584838898
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8339357190892337068}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 1172102457425465809, guid: b48603b1f2d0d6f428723f0d89e4dafc, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &8442525676262455151
GameObject:
m_ObjectHideFlags: 0
@@ -6935,6 +7599,81 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &8891292652493349475
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4789218457072247502}
- component: {fileID: 3389991985103273735}
- component: {fileID: 2938340339765009532}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &4789218457072247502
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8891292652493349475}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6419923115795927302}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.6977236, y: 0.32699218}
m_AnchorMax: {x: 0.6977236, y: 0.32699218}
m_AnchoredPosition: {x: -19.179, y: 16.782}
m_SizeDelta: {x: 42.5956, y: 40.1846}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3389991985103273735
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8891292652493349475}
m_CullTransparentMesh: 1
--- !u!114 &2938340339765009532
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8891292652493349475}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: -7462228084874713130, guid: cad5616c19ca266448fcf54f97fe766d, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &8926842291454856642
GameObject:
m_ObjectHideFlags: 0
@@ -6969,7 +7708,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 163.2, y: 0}
m_AnchoredPosition: {x: 232.8, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3583705284184792287
@@ -7007,13 +7746,13 @@ MonoBehaviour:
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 61
m_Alignment: 4
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 114
m_Text: player_rks
--- !u!1 &9065634752865683599
GameObject:
m_ObjectHideFlags: 0
@@ -1,6 +1,8 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
public class btmandtopController : MonoBehaviour
{
@@ -31,12 +33,22 @@ public class btmandtopController : MonoBehaviour
public GameObject email_prefab;
public GameObject notice_prefab;
[Header("New Back Buttons")]
[SerializeField] private Button back_navButton;
[SerializeField] private Button home_navButton;
[SerializeField] private Button settings_navButton;
[SerializeField] private string homeSceneName = "UI_UI";
[SerializeField] private string backFallbackSceneName = "Main_main";
private UnityAction instantiateSettings;
private UnityAction instantiateUserInfo;
private UnityAction instantiateStore;
private UnityAction instantiateShowLevel;
private UnityAction instantiateEmail;
private UnityAction instantiateNotice;
private UnityAction navBackAction;
private UnityAction navHomeAction;
private UnityAction navSettingsAction;
// cached reference to the settings instance to ensure only one exists
private GameObject settingsInstance;
@@ -46,10 +58,16 @@ public class btmandtopController : MonoBehaviour
private CanvasGroup musicPicGroup;
private Coroutine musicPicFade;
private bool musicPicVisible = true;
private bool navSceneLoading = false;
private static readonly List<string> sceneHistory = new List<string>();
private static bool sceneHistoryHooked = false;
private static string trackedCurrentScene = string.Empty;
void Awake()
{
EnsureMusicPicRoot();
InitializeSceneHistoryIfNeeded();
}
void Start()
@@ -85,6 +103,8 @@ public class btmandtopController : MonoBehaviour
if (notice_display != null)
notice_display.onClick.AddListener(instantiateNotice);
BindNewBackButtons();
EnsureMusicPicRoot();
SetupMusicPicDefault();
if (button_Music != null)
@@ -112,6 +132,7 @@ public class btmandtopController : MonoBehaviour
if (settingsInstance == null)
{
settingsInstance = Instantiate(settings_prefab, putPrefabsHere.transform);
EnsureSettingsEnterAnimator(settingsInstance);
settingsInstance.SetActive(false);
// try to set canvas camera now as in previous behavior
@@ -135,6 +156,7 @@ public class btmandtopController : MonoBehaviour
{
// ensure it's parented correctly under putPrefabsHere
settingsInstance.transform.SetParent(putPrefabsHere.transform, false);
EnsureSettingsEnterAnimator(settingsInstance);
settingsInstance.SetActive(false);
}
}
@@ -309,6 +331,13 @@ public class btmandtopController : MonoBehaviour
if (button_Music != null)
button_Music.onClick.RemoveListener(ToggleMusicPicLocal);
if (back_navButton != null && navBackAction != null)
back_navButton.onClick.RemoveListener(navBackAction);
if (home_navButton != null && navHomeAction != null)
home_navButton.onClick.RemoveListener(navHomeAction);
if (settings_navButton != null && navSettingsAction != null)
settings_navButton.onClick.RemoveListener(navSettingsAction);
}
private void ToggleSettingsPrefab()
@@ -319,6 +348,7 @@ public class btmandtopController : MonoBehaviour
if (settingsInstance == null)
{
settingsInstance = Instantiate(settings_prefab, putPrefabsHere.transform);
EnsureSettingsEnterAnimator(settingsInstance);
// attempt to set canvas camera
try
@@ -341,6 +371,8 @@ public class btmandtopController : MonoBehaviour
return;
}
EnsureSettingsEnterAnimator(settingsInstance);
// Toggle active state
bool active = settingsInstance.activeSelf;
settingsInstance.SetActive(!active);
@@ -445,4 +477,174 @@ public class btmandtopController : MonoBehaviour
instance = null;
}
}
private void EnsureSettingsEnterAnimator(GameObject instance)
{
if (instance == null) return;
UI_SettingsPanelEnterAnim anim = instance.GetComponent<UI_SettingsPanelEnterAnim>();
if (anim == null)
anim = instance.AddComponent<UI_SettingsPanelEnterAnim>();
anim.enabled = true;
}
private void BindNewBackButtons()
{
ResolveNewBackButtons();
navBackAction = OnBackNavClicked;
navHomeAction = OnHomeNavClicked;
navSettingsAction = OnSettingsNavClicked;
if (back_navButton != null)
{
back_navButton.onClick.RemoveListener(navBackAction);
back_navButton.onClick.AddListener(navBackAction);
}
if (home_navButton != null)
{
home_navButton.onClick.RemoveListener(navHomeAction);
home_navButton.onClick.AddListener(navHomeAction);
}
if (settings_navButton != null)
{
settings_navButton.onClick.RemoveListener(navSettingsAction);
settings_navButton.onClick.AddListener(navSettingsAction);
}
}
private void ResolveNewBackButtons()
{
Transform navRoot = FindChildRecursive(transform, "New back");
if (navRoot == null)
{
GameObject sceneRoot = FindByName("New back");
if (sceneRoot != null)
navRoot = sceneRoot.transform;
}
if (back_navButton == null)
back_navButton = FindButtonByName(navRoot, "back");
if (home_navButton == null)
home_navButton = FindButtonByName(navRoot, "home");
if (settings_navButton == null)
settings_navButton = FindButtonByName(navRoot, "settings");
}
private static Transform FindChildRecursive(Transform root, string childName)
{
if (root == null || string.IsNullOrEmpty(childName)) return null;
if (root.name == childName) return root;
for (int i = 0; i < root.childCount; i++)
{
Transform child = root.GetChild(i);
Transform found = FindChildRecursive(child, childName);
if (found != null) return found;
}
return null;
}
private static Button FindButtonByName(Transform root, string name)
{
if (string.IsNullOrEmpty(name)) return null;
if (root != null)
{
Button[] buttons = root.GetComponentsInChildren<Button>(true);
for (int i = 0; i < buttons.Length; i++)
{
Button btn = buttons[i];
if (btn != null && string.Equals(btn.gameObject.name, name, System.StringComparison.OrdinalIgnoreCase))
return btn;
}
}
return null;
}
private static void InitializeSceneHistoryIfNeeded()
{
if (sceneHistoryHooked) return;
sceneHistoryHooked = true;
trackedCurrentScene = SceneManager.GetActiveScene().name ?? string.Empty;
SceneManager.sceneLoaded += OnSceneLoadedTrackHistory;
}
private static void OnSceneLoadedTrackHistory(Scene scene, LoadSceneMode mode)
{
string incoming = scene.name ?? string.Empty;
if (!string.IsNullOrEmpty(trackedCurrentScene) &&
!string.Equals(trackedCurrentScene, incoming, System.StringComparison.OrdinalIgnoreCase))
{
if (sceneHistory.Count == 0 ||
!string.Equals(sceneHistory[sceneHistory.Count - 1], trackedCurrentScene, System.StringComparison.OrdinalIgnoreCase))
{
sceneHistory.Add(trackedCurrentScene);
if (sceneHistory.Count > 24) sceneHistory.RemoveAt(0);
}
}
trackedCurrentScene = incoming;
}
private static string PopPreviousSceneName(string currentScene)
{
for (int i = sceneHistory.Count - 1; i >= 0; i--)
{
string candidate = sceneHistory[i];
sceneHistory.RemoveAt(i);
if (string.IsNullOrEmpty(candidate)) continue;
if (string.Equals(candidate, currentScene, System.StringComparison.OrdinalIgnoreCase)) continue;
return candidate;
}
return null;
}
private void OnBackNavClicked()
{
if (navSceneLoading) return;
InitializeSceneHistoryIfNeeded();
string current = SceneManager.GetActiveScene().name ?? string.Empty;
string target = PopPreviousSceneName(current);
if (string.IsNullOrEmpty(target))
{
target = string.IsNullOrEmpty(backFallbackSceneName) ? "Main_main" : backFallbackSceneName;
}
if (!string.IsNullOrEmpty(target) &&
!string.Equals(target, current, System.StringComparison.OrdinalIgnoreCase))
{
StartCoroutine(LoadNavSceneAsync(target));
}
}
private void OnHomeNavClicked()
{
if (navSceneLoading) return;
string target = string.IsNullOrEmpty(homeSceneName) ? "UI_UI" : homeSceneName;
StartCoroutine(LoadNavSceneAsync(target));
}
private void OnSettingsNavClicked()
{
ToggleSettingsPrefab();
}
private System.Collections.IEnumerator LoadNavSceneAsync(string sceneName)
{
if (string.IsNullOrEmpty(sceneName)) yield break;
if (navSceneLoading) yield break;
navSceneLoading = true;
Time.timeScale = 1f;
AsyncOperation op = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
while (op != null && !op.isDone)
{
yield return null;
}
navSceneLoading = false;
}
}