public static void ClosePopUp(UIPopUpController controller) { if (controller.Handler != null) { try { controller.Handler.PopUpDidFinish(controller); } catch (Exception e) { MonoLog.Log(MonoLogChannel.UI, e); } } if (PopUpClose != null) { PopUpClose(controller); } UnityEngine.Object.Destroy(controller.gameObject); }
public static T OpenPopUp <T>(UIController parentController, params object[] args) where T : UIPopUpController { _args.Push(args); bool oneItemOnScene = false; foreach (Attribute eachAttribute in typeof(T).GetCustomAttributes(false)) { if (eachAttribute is SingletoneAttribute) { oneItemOnScene = true; break; } } if (oneItemOnScene) { T existingController = (T)UnityEngine.Object.FindObjectOfType(typeof(T)); if (existingController != null) { UIManager.ClosePopUp(existingController); } } UIPopUpController controller = PopUpFactory.CreateInstance <T>(parentController); if (PopUpOpen != null) { PopUpOpen(controller); } if (parentController is IUIPopUpControllerHandler) { controller.Handler = (IUIPopUpControllerHandler)parentController; } return(controller as T); }