You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XWFramework.Tools;
|
|
using System;
|
|
namespace XWFramework.UI {
|
|
public class UIManager : MonoSingleton<UIManager>
|
|
{
|
|
public GameObject canvas;
|
|
public Dictionary<UIType, UIPanel> uiDicts { get; private set; }
|
|
|
|
[NonSerialized]
|
|
public UIPanel oftenShow;
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
uiDicts = new Dictionary<UIType, UIPanel>();
|
|
for (int i = 0; i < canvas.transform.childCount; i++)
|
|
{
|
|
canvas.transform.GetChild(i).gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void Register(UIPanel panel) {
|
|
if (uiDicts.ContainsKey(panel.type)) {
|
|
return;
|
|
}
|
|
Debug.Log("注册 " + panel.type);
|
|
uiDicts.Add(panel.type, panel);
|
|
panel.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void CloseAll() {
|
|
foreach (var ui in canvas.GetComponentsInChildren<RectTransform>())
|
|
{
|
|
ui.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void Show(UIType uitype) {
|
|
uiDicts[uitype].gameObject.SetActive(true);
|
|
}
|
|
|
|
public void Show(UIType uitype, UIType uitype2)
|
|
{
|
|
uiDicts[uitype].gameObject.SetActive(true);
|
|
uiDicts[uitype2].gameObject.SetActive(true);
|
|
}
|
|
|
|
public void Close(UIType uitype) {
|
|
uiDicts[uitype].gameObject.SetActive(false);
|
|
}
|
|
|
|
public void Close(UIType uitype, UIType uitype2)
|
|
{
|
|
uiDicts[uitype].gameObject.SetActive(false);
|
|
uiDicts[uitype2].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|