/// <summary> /// 关闭界面 /// </summary> /// <param name="uiFormBase">要关闭的界面</param> /// <param name="userData">用户自定义数据</param> public void CloseUIForm(UIFormBase uiFormBase, object userData) { if (uiFormBase == null) { throw new Exception("UI form is invalid."); } UIGroup uiGroup = uiFormBase.UIGroup; if (uiGroup == null) { throw new Exception("UI group is invalid."); } uiGroup.RemoveUIForm(uiFormBase); uiFormBase.OnClose(userData); uiGroup.Refresh(); if (m_CloseUIFormCompleteEventHandler != null) { m_CloseUIFormCompleteEventHandler(uiFormBase.SerialId, uiFormBase.UIFormAssetName, uiGroup, userData); } m_RecycleQueue.Enqueue(uiFormBase); }
/// <summary> /// 是否是合法的界面 /// </summary> /// <param name="uiForm">界面</param> /// <returns>界面是否合法</returns> public bool IsValidUIForm(UIFormBase uiForm) { if (uiForm == null) { return(false); } return(HasUIForm(uiForm.SerialId)); }
private void OnOpenUIFormSuccess(UIFormBase uiForm, float duration, object userData) { Log.Info("Open UI form success, uiform name '{0}',duration time '{1}'.", uiForm.UIFormAssetName, duration); if (m_EnableOpenUIFormSuccessEvent) { //todo //Debug.Log("加载UI资源成功"+ duration); } }
/// <summary> /// 设置界面是否被加锁 /// </summary> /// <param name="uiForm">要设置是否被加锁的界面</param> /// <param name="locked">界面是否被加锁</param> public void SetUIFormInstanceLocked(UIFormBase uiForm, bool locked) { if (uiForm == null) { Log.Warning("UI form is invalid."); return; } m_UIManager.SetUIFormInstanceLocked(uiForm.gameObject, locked); }
/// <summary> /// 设置界面的优先级 /// </summary> /// <param name="uiForm">要设置优先级的界面</param> /// <param name="priority">界面优先级</param> public void SetUIFormInstancePriority(UIFormBase uiForm, int priority) { if (uiForm == null) { Log.Warning("UI form is invalid."); return; } m_UIManager.SetUIFormInstancePriority(uiForm.gameObject, priority); }
/// <summary> /// 获取界面 /// </summary> /// <param name="uiFormAssetName">界面资源名称</param> /// <returns>要获取的界面</returns> public UIFormBase[] GetUIForms(string uiFormAssetName) { UIFormBase[] uiForms = m_UIManager.GetUIForms(uiFormAssetName); UIFormBase[] uiFormImpls = new UIFormBase[uiForms.Length]; for (int i = 0; i < uiForms.Length; i++) { uiFormImpls[i] = uiForms[i]; } return(uiFormImpls); }
/// <summary> /// 获取所有已加载的界面 /// </summary> /// <returns>所有已加载的界面</returns> public UIFormBase[] GetAllLoadedUIForms() { UIFormBase[] uiForms = m_UIManager.GetAllLoadedUIForms(); UIFormBase[] uiFormImpls = new UIFormBase[uiForms.Length]; for (int i = 0; i < uiForms.Length; i++) { uiFormImpls[i] = uiForms[i]; } return(uiFormImpls); }
/// <summary> /// 初始化界面组界面信息的新实例 /// </summary> /// <param name="uiForm">界面</param> public UIFormInfo(UIFormBase uiFormBase) { if (uiFormBase == null) { throw new Exception("UI form is invalid."); } m_UIFormBase = uiFormBase; m_Paused = true; m_Covered = true; }
/// <summary> /// 激活界面 /// </summary> /// <param name="uiFormBase">要激活的界面</param> /// <param name="userData">用户自定义数据</param> public void RefocusUIForm(UIFormBase uiFormBase, object userData) { UIFormInfo uiFormInfo = GetUIFormInfo(uiFormBase); if (uiFormInfo == null) { throw new Exception("Can not find UI form info."); } m_UIFormInfos.Remove(uiFormInfo); m_UIFormInfos.AddFirst(uiFormInfo); }
/// <summary> /// 获取界面 /// </summary> /// <param name="serialId">界面序列编号</param> /// <returns>要获取的界面</returns> public UIFormBase GetUIForm(int serialId) { foreach (KeyValuePair <string, UIGroup> uiGroup in m_UIGroups) { UIFormBase uiForm = uiGroup.Value.GetUIForm(serialId); if (uiForm != null) { return(uiForm); } } return(null); }
/// <summary> /// 界面管理器轮询 /// </summary> public void OnUpdate(float deltaTime, float unscaledDeltaTime) { while (m_RecycleQueue.Count > 0) { UIFormBase uiForm = m_RecycleQueue.Dequeue(); uiForm.OnRecycle(); m_InstancePool.Unspawn(uiForm.Handle); } foreach (KeyValuePair <string, UIGroup> uiGroup in m_UIGroups) { uiGroup.Value.OnUpdate(deltaTime, unscaledDeltaTime); } }
/// <summary> /// 关闭界面 /// </summary> /// <param name="serialId">要关闭界面的序列编号</param> /// <param name="userData">用户自定义数据</param> public void CloseUIForm(int serialId, object userData) { if (IsLoadingUIForm(serialId)) { m_UIFormsToReleaseOnLoad.Add(serialId); return; } UIFormBase uiFormBase = GetUIForm(serialId); if (uiFormBase == null) { throw new Exception(TextUtil.Format("Can not find UI form '{0}'.", serialId.ToString())); } CloseUIForm(uiFormBase, userData); }
private UIFormInfo GetUIFormInfo(UIFormBase uiFormBase) { if (uiFormBase == null) { throw new Exception("UI form is invalid."); } foreach (UIFormInfo uiFormInfo in m_UIFormInfos) { if (uiFormInfo.UIFormBase == uiFormBase) { return(uiFormInfo); } } return(null); }
/// <summary> /// 获取界面 /// </summary> /// <param name="uiFormAssetName">界面资源名称</param> /// <returns>要获取的界面</returns> public UIFormBase GetUIForm(string uiFormAssetName) { if (string.IsNullOrEmpty(uiFormAssetName)) { throw new Exception("UI form asset name is invalid."); } foreach (KeyValuePair <string, UIGroup> uiGroup in m_UIGroups) { UIFormBase uiFormBase = uiGroup.Value.GetUIForm(uiFormAssetName); if (uiFormBase != null) { return(uiFormBase); } } return(null); }
/// <summary> /// 激活界面 /// </summary> /// <param name="uiForm">要激活的界面</param> /// <param name="userData">用户自定义数据</param> public void RefocusUIForm(UIFormBase uiForm, object userData) { if (uiForm == null) { throw new Exception("UI form is invalid."); } UIGroup uiGroup = uiForm.UIGroup; if (uiGroup == null) { throw new Exception("UI group is invalid."); } uiGroup.RefocusUIForm(uiForm, userData); uiGroup.Refresh(); uiForm.OnRefocus(userData); }
private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData) { try { GameObject gameObject = uiFormInstance as GameObject; if (gameObject == null) { Log.Error("UI form instance is invalid."); } Transform transform = gameObject.transform; transform.SetParent(uiGroup.UIGroupTransform); transform.localScale = Vector3.one; UIFormBase uiFormBase = transform.GetComponent <UIFormBase>(); if (uiFormBase == null) { throw new Exception("Can't find UI form."); } uiFormBase.OnInit(serialId, uiFormAssetName, uiGroup, pauseCoveredUIForm, isNewInstance, userData); uiGroup.AddUIForm(uiFormBase); uiFormBase.OnOpen(userData); uiGroup.Refresh(); if (m_OpenUIFormSuccessEventHandler != null) { m_OpenUIFormSuccessEventHandler(uiFormBase, duration, userData); } } catch (Exception exception) { if (m_OpenUIFormFailureEventHandler != null) { m_OpenUIFormFailureEventHandler(serialId, uiFormAssetName, uiGroup.Name, pauseCoveredUIForm, exception.ToString(), userData); return; } throw; } }
/// <summary> /// 从界面组移除界面 /// </summary> /// <param name="uiFormBase">要移除的界面</param> public void RemoveUIForm(UIFormBase uiFormBase) { UIFormInfo uiFormInfo = GetUIFormInfo(uiFormBase); if (uiFormInfo == null) { throw new Exception(TextUtil.Format("Can not find UI form info for serial id '{0}', UI form asset name is '{1}'.", uiFormBase.SerialId.ToString(), uiFormBase.UIFormAssetName)); } if (!uiFormInfo.Covered) { uiFormInfo.Covered = true; uiFormBase.OnCover(); } if (!uiFormInfo.Paused) { uiFormInfo.Paused = true; uiFormBase.OnPause(); } m_UIFormInfos.Remove(uiFormInfo); }
/// <summary> /// 激活界面 /// </summary> /// <param name="uiForm">要激活的界面</param> /// <param name="userData">用户自定义数据</param> public void RefocusUIForm(UIFormBase uiForm, object userData) { m_UIManager.RefocusUIForm(uiForm, userData); }
/// <summary> /// 激活界面 /// </summary> /// <param name="uiForm">要激活的界面</param> public void RefocusUIForm(UIFormBase uiForm) { m_UIManager.RefocusUIForm(uiForm); }
/// <summary> /// 关闭界面 /// </summary> /// <param name="uiForm">要关闭的界面</param> /// <param name="userData">用户自定义数据</param> public void CloseUIForm(UIFormBase uiForm, object userData) { m_UIManager.CloseUIForm(uiForm, userData); }
/// <summary> /// 关闭界面 /// </summary> /// <param name="uiForm">要关闭的界面</param> public void CloseUIForm(UIFormBase uiForm) { m_UIManager.CloseUIForm(uiForm); }
/// <summary> /// 是否是合法的界面 /// </summary> /// <param name="uiForm">界面</param> /// <returns>界面是否合法</returns> public bool IsValidUIForm(UIFormBase uiForm) { return(m_UIManager.IsValidUIForm(uiForm)); }
/// <summary> /// 关闭界面 /// </summary> /// <param name="uiFormBase">要关闭的界面</param> public void CloseUIForm(UIFormBase uiFormBase) { CloseUIForm(uiFormBase, null); }
/// <summary> /// 激活界面 /// </summary> /// <param name="uiForm">要激活的界面</param> public void RefocusUIForm(UIFormBase uiForm) { RefocusUIForm(uiForm, null); }
/// <summary> /// 往界面组增加界面 /// </summary> /// <param name="uiFormBase">要增加的界面</param> public void AddUIForm(UIFormBase uiFormBase) { UIFormInfo uiFormInfo = new UIFormInfo(uiFormBase); m_UIFormInfos.AddFirst(uiFormInfo); }