using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace RichFrame.UIFrame { public class UIManager : Singleton { public Dictionary uiForms = new Dictionary(); List showingForms = new List(); /// /// 注册一个UI面板 /// /// /// public void RegisterUIForm(string formName, UIForm uiForm) { uiForms.Add(formName, uiForm); } /// /// 显示UI /// /// public void ShowForm(string formName) { UIForm f; if (uiForms.TryGetValue(formName, out f)) { f.Display(); switch (f.showType) { case UIForm.ShowType.Normal: break; case UIForm.ShowType.Popup: break; case UIForm.ShowType.HideOther: HideAll(); break; default: break; } showingForms.Add(f); } } /// /// 隐藏UI /// /// public void HideForm(string formName) { UIForm f; if (uiForms.TryGetValue(formName, out f)) { switch (f.showType) { case UIForm.ShowType.Normal: break; case UIForm.ShowType.Popup: break; case UIForm.ShowType.HideOther: ShowAll(); break; default: break; } showingForms.Remove(f); f.Close(); } } void HideAll() { foreach (var item in showingForms) { item.gameObject.SetActive(false); } } void ShowAll() { foreach (var item in showingForms) { item.gameObject.SetActive(true); } } } }