UI框架开发中

This commit is contained in:
2025-09-29 11:03:26 +08:00
parent 71edbb6088
commit 3ea4257e2d
24 changed files with 292 additions and 266 deletions

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using UnityEngine;
using YooAsset;
public class UIManager : SingletonMono<UIManager>
public class UIManager : Singleton<UIManager>
{
Transform uiRoot;
Dictionary<string, UIBaseWindow> openedWindows = new Dictionary<string, UIBaseWindow>();
@@ -20,9 +20,10 @@ public class UIManager : SingletonMono<UIManager>
{
YooAssets.LoadAssetAsync<GameObject>(windowName).Completed += handle =>
{
GameObject go = Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform);
GameObject go = GameObject.Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform);
var window = go.GetComponent<T>();
window.Show();
openedWindows[windowName] = window;
onShow?.Invoke(window);
};
}
@@ -33,5 +34,20 @@ public class UIManager : SingletonMono<UIManager>
{
openedWindows[windowName].Hide();
}
else
{
Debug.Log(<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ڣ<EFBFBD>ʹ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
public bool CheckShow(string windowName)
{
if (openedWindows.ContainsKey(windowName))
{
return openedWindows[windowName].gameObject.activeSelf;
}
else
{
return false;
}
}
}