public UiBaseController <T> CreateAndShowUi <T>(string uiName, UiBaseController <T> prefab, Action <bool> callback = null) where T : UiBaseView { var target = CreateUi(uiName, prefab); if (target == null) { callback?.Invoke(false); return(null); } target.gameObject.SetActive(true); callback?.Invoke(true); return(target); }
public UiBaseController <T> CreateUi <T>(string uiName, UiBaseController <T> prefab) where T : UiBaseView { if (string.IsNullOrEmpty(uiName)) { Debug.LogError($"Ui name is empty!"); return(null); } if (Controllers.TryGetValue(uiName, out var target)) { Debug.LogWarning($"Ui {uiName} already created!"); return(target as UiBaseController <T>); } var instance = Instantiate(prefab); instance.gameObject.name = uiName; instance.gameObject.SetActive(false); instance.transform.SetParent(Instance.uiRoot, false); Controllers.Add(uiName, instance); return(instance); }