111
This commit is contained in:
@@ -6,7 +6,8 @@ using YooAsset;
|
||||
|
||||
public class UIManager : Singleton<UIManager>
|
||||
{
|
||||
public Dictionary<string, UIBase> openedUIs = new Dictionary<string, UIBase>();
|
||||
Dictionary<string, UIBase> openedUIs = new Dictionary<string, UIBase>();
|
||||
Dictionary<string, AssetHandle> assetHandles = new Dictionary<string, AssetHandle>();
|
||||
Stack<UIBase> uiStack = new Stack<UIBase>();
|
||||
|
||||
public T ShowUI<T>(string uiName, RectTransform parent = null, bool isFull = false) where T : UIBase
|
||||
@@ -59,18 +60,36 @@ public class UIManager : Singleton<UIManager>
|
||||
}
|
||||
GameObject LoadUI(string uiType)
|
||||
{
|
||||
AssetHandle uiHandle = YooAssets.LoadAssetSync<GameObject>(uiType);
|
||||
return (GameObject)uiHandle.AssetObject;
|
||||
if (!assetHandles.ContainsKey(uiType))
|
||||
{
|
||||
AssetHandle uiHandle = YooAssets.LoadAssetSync<GameObject>(uiType);
|
||||
assetHandles.Add(uiType, uiHandle);
|
||||
return (GameObject)uiHandle.AssetObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetHandle uiHandle = assetHandles[uiType];
|
||||
return (GameObject)uiHandle.AssetObject;
|
||||
}
|
||||
}
|
||||
async UniTask<GameObject> LoadUIAsync(string uiType)
|
||||
{
|
||||
AssetHandle uiHandle = YooAssets.LoadAssetAsync<GameObject>(uiType);
|
||||
await uiHandle.ToUniTask();
|
||||
return (GameObject)uiHandle.AssetObject;
|
||||
if (!assetHandles.ContainsKey(uiType))
|
||||
{
|
||||
AssetHandle uiHandle = YooAssets.LoadAssetAsync<GameObject>(uiType);
|
||||
await uiHandle.ToUniTask();
|
||||
assetHandles.Add(uiType, uiHandle);
|
||||
return (GameObject)uiHandle.AssetObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetHandle uiHandle = assetHandles[uiType];
|
||||
return (GameObject)uiHandle.AssetObject;
|
||||
}
|
||||
}
|
||||
|
||||
#region 用于测试没挂载UIBase的
|
||||
public Dictionary<string, GameObject> testOpenedUIs = new Dictionary<string, GameObject>();
|
||||
Dictionary<string, GameObject> testOpenedUIs = new Dictionary<string, GameObject>();
|
||||
Stack<GameObject> testUIStack = new Stack<GameObject>();
|
||||
public GameObject TestShowUI(string path, string uiName, RectTransform parent = null, bool isFull = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user