/// <summary> /// Hides the specified view and returns its data. /// </summary> public static MvcParameter HideView(IMvcView view) { MvcParameter returnData = view.OnViewHide(); DoCallback(view.ViewId, returnData); return(returnData); }
/// <summary> /// Invokes the callback attached to the specified view id. /// </summary> public static void DoCallback(int viewId, MvcParameter returnData) { if (I.uiCallbacks.ContainsKey(viewId)) { I.uiCallbacks[viewId].Invoke(returnData); I.uiCallbacks.Remove(viewId); } }
/// <summary> /// Shows the specified view with parameters. /// </summary> public static IMvcView ShowView(Type viewType, MvcParameter param = null) { // Unregistered type is an invalid request. if (!I.uiMetadatas.ContainsKey(viewType)) { Debug.LogWarning("MVC.ShowView - No MVC metadata found for specified type: " + viewType.FullName); return(null); } // Null-checks are dirty, so we just pass a non-null value. if (param == null) { param = new MvcParameter(); } // Show view var view = I.uiMetadatas[viewType].OnShow(NextViewID, param); I.activeViews.Add(view); return(view); }
/// <summary> /// Use this method to handle re-initialization of fields, resources, etc. /// Will invoke OnViewShow() afterwards. /// Called everytime this view is being recycled. /// </summary> public virtual void OnRecycle(int viewId, MvcParameter param) { this.viewId = viewId; isDestroyed = false; }
/// <summary> /// Use this method to handle initialization of fields, resources, etc. /// Called ONLY once after Awake() and OnAdaptView(). /// </summary> public virtual void OnInitialize(int viewId, MvcParameter param) { this.viewId = viewId; isDestroyed = false; }