using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using YooAsset; public class UIManager : SingletonMono { Transform uiRoot; Dictionary openedWindows = new Dictionary(); public void ShowWindow(string windowName,Action onShow = null) where T : UIBaseWindow { if (openedWindows.ContainsKey(windowName)) { var window = openedWindows[windowName] as T; window.Show(); onShow?.Invoke(window); } else { YooAssets.LoadAssetAsync(windowName).Completed += handle => { GameObject go = Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform); var window = go.GetComponent(); window.Show(); onShow?.Invoke(window); }; } } public void HideWindow(string windowName) { if (openedWindows.ContainsKey(windowName)) { openedWindows[windowName].Hide(); } } }