超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public static class UI_SelectSong_AutoPlayToggleBinder
|
||||
{
|
||||
private const string TargetSceneName = "selectYourSongFirst";
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void Init()
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
if (scene.name != TargetSceneName)
|
||||
return;
|
||||
|
||||
TryBind(scene);
|
||||
}
|
||||
|
||||
private static void TryBind(Scene scene)
|
||||
{
|
||||
// Ensure we have the latest persisted value (important when entering from editor play).
|
||||
GameConfig.LoadPrefs();
|
||||
|
||||
// Prefer the user's specified hierarchy if present (active only).
|
||||
GameObject go =
|
||||
GameObject.Find("rightInfos/difficultyBtnInfos/difficultyBtnInfos/select_Auto") ??
|
||||
GameObject.Find("rightInfos/difficultyBtnInfos/select_Auto");
|
||||
|
||||
if (go == null)
|
||||
{
|
||||
// Fallback: search by name in this scene (includes inactive objects).
|
||||
var transforms = Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
for (int i = 0; i < transforms.Length; i++)
|
||||
{
|
||||
var t = transforms[i];
|
||||
if (t == null) continue;
|
||||
if (t.gameObject.scene != scene) continue;
|
||||
if (t.name != "select_Auto") continue;
|
||||
go = t.gameObject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (go == null)
|
||||
{
|
||||
if (GameConfig.verboseLogs)
|
||||
Debug.LogWarning("[AutoPlay] select_Auto button not found in selectYourSongFirst scene. Autoplay toggle UI will be unavailable.");
|
||||
return;
|
||||
}
|
||||
|
||||
var toggle = go.GetComponent<UI_SelectSong_AutoPlayToggle>();
|
||||
if (toggle == null)
|
||||
toggle = go.AddComponent<UI_SelectSong_AutoPlayToggle>();
|
||||
|
||||
toggle.TryAutoWire();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user