主界面添加,许多bug修复。祝贺黑盒1如期开始

This commit is contained in:
FloatGaming
2026-03-02 04:34:13 +08:00
parent e11cc1da7a
commit 3c1d263ef1
308 changed files with 59216 additions and 32756 deletions
+78
View File
@@ -0,0 +1,78 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public static class UISystemBootstrap
{
private const string defaultConfigPath = "UISoundConfig_Default";
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
static void Init()
{
CreateRouterIfNeeded();
RegisterAll();
SceneManager.sceneLoaded += OnSceneLoaded;
}
static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
RegisterAll();
}
static void CreateRouterIfNeeded()
{
UISoundRouter router;
if (UISoundRouter.Instance != null)
{
router = UISoundRouter.Instance;
}
else
{
GameObject go = new GameObject("UISoundRouter");
router = go.AddComponent<UISoundRouter>();
Object.DontDestroyOnLoad(go);
}
var config = Resources.Load<UISoundConfig>(defaultConfigPath);
if (config != null)
{
router.SetConfig(config);
}
else
{
Debug.LogWarning("UISoundConfig not found in Resources at: " + defaultConfigPath);
}
}
public static void RegisterAll()
{
Debug.Log("RegisterButtons Called");
// Find all Selectable objects (includes Button, Toggle, Slider, etc.)
Selectable[] selectables = Object.FindObjectsOfType<Selectable>(true);
foreach (var sel in selectables)
{
Register(sel);
}
}
public static void RegisterHierarchy(GameObject root)
{
if (root == null) return;
Selectable[] selectables = root.GetComponentsInChildren<Selectable>(true);
foreach (var sel in selectables)
{
Register(sel);
}
}
public static void Register(Selectable sel)
{
if (sel == null) return;
if (sel.GetComponent<UIButtonInteraction>() == null)
{
sel.gameObject.AddComponent<UIButtonInteraction>();
}
}
}