48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using ZXL.Manager;
|
||
|
|
||
|
namespace ZXL.Scripts.UI
|
||
|
{
|
||
|
public enum UIType
|
||
|
{
|
||
|
LoginUI,
|
||
|
AssetsUI,
|
||
|
PushModelUI,
|
||
|
ConctrolUI,
|
||
|
}
|
||
|
|
||
|
public class UIManager : Manager<UIManager>
|
||
|
{
|
||
|
Dictionary<UIType, UIBase> dic = new Dictionary<UIType, UIBase>();
|
||
|
|
||
|
public override void OnAwake()
|
||
|
{
|
||
|
base.OnAwake();
|
||
|
var uiBases = GameObject.FindObjectsOfType<UIBase>();
|
||
|
foreach (var uiBase in uiBases)
|
||
|
{
|
||
|
dic.Add(uiBase.uiType, uiBase);
|
||
|
uiBase.Close();
|
||
|
Debug.Log($"[{uiBase.uiType.ToString()}] UIBase: {uiBase}");
|
||
|
}
|
||
|
Open(UIType.AssetsUI);
|
||
|
}
|
||
|
|
||
|
public UIBase Open(UIType uiType)
|
||
|
{
|
||
|
dic[uiType].Open();
|
||
|
return dic[uiType];
|
||
|
}
|
||
|
|
||
|
public UIBase GetUI(UIType uiType)
|
||
|
{
|
||
|
return dic[uiType];
|
||
|
}
|
||
|
|
||
|
public void Close(UIType uiType)
|
||
|
{
|
||
|
dic[uiType].Close();
|
||
|
}
|
||
|
}
|
||
|
}
|