/// <summary> /// 打开界面。 /// </summary> /// <param name="uiFormAssetName">界面资源名称。</param> /// <param name="uiGroupName">界面组名称。</param> /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>界面的序列编号。</returns> public bool OpenUIForm(string uiFormAssetName, string uiGroupName, bool pauseCoveredUIForm, object userData) { if (m_ResourceManager == null) { Log.Error("You must set resource manager first."); } if (string.IsNullOrEmpty(uiFormAssetName)) { Log.Error("UI form asset name is invalid."); } if (string.IsNullOrEmpty(uiGroupName)) { Log.Error("UI group name is invalid."); } if (IsLoadingUIForm(uiFormAssetName)) { Log.Error("UI group name is loading."); return(false); } if (HasUIForm(uiFormAssetName)) { IUIGroup uiGroup1 = GetUIGroup(uiGroupName); IUIForm form = uiGroup1.GetUIForm(uiFormAssetName); if (uiGroup1.CurrentUIForm != null && uiGroup1.CurrentUIForm.SerialId != form.SerialId) { uiGroup1.CurrentUIForm.OnClose(null); } uiGroup1.RefocusUIForm(form, userData); uiGroup1.Refresh(); return(true); } UIGroup uiGroup = (UIGroup)GetUIGroup(uiGroupName); if (uiGroup == null) { Log.Error(string.Format("UI group '{0}' is not exist.", uiGroupName)); } //资源是否缓存 // ... ... UIFormInstanceObject uiFormInstanceObject = null; if (uiFormInstanceObject == null) { m_UIFormsBeingLoaded.Add(uiFormAssetName.GetHashCode()); m_UIFormAssetNamesBeingLoaded.Add(uiFormAssetName); m_ResourceManager.LoadAsset(uiFormAssetName, m_LoadAssetCallbacks, new OpenUIFormInfo(uiFormAssetName.GetHashCode(), uiGroup, userData)); } else { InternalOpenUIForm(uiFormAssetName.GetHashCode(), uiFormAssetName, uiGroup, uiFormInstanceObject.Target, false, 0f, userData); } return(true); }
private void LoadUIFormSuccessCallback(string uiFormAssetName, object uiFormAsset, float duration, object userData) { OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData; if (openUIFormInfo == null) { throw new GameFrameworkException("Open UI form info is invalid."); } if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId)) { m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId); ReferencePool.Release(openUIFormInfo); m_UIFormHelper.ReleaseUIForm(uiFormAsset, null); return; } m_UIFormsBeingLoaded.Remove(openUIFormInfo.SerialId); UIFormInstanceObject uiFormInstanceObject = UIFormInstanceObject.Create(uiFormAssetName, uiFormAsset, m_UIFormHelper.InstantiateUIForm(uiFormAsset), m_UIFormHelper); m_InstancePool.Register(uiFormInstanceObject, true); InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData); ReferencePool.Release(openUIFormInfo); }
private void LoadUIFormSuccessCallback(string uiFormAssetName, object uiFormAsset, float duration, object userData) { OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData; if (openUIFormInfo == null) { throw new System.Exception("Open UI form info is invalid."); } UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormAsset, m_UIFormHelper.InstantiateUIForm(uiFormAsset), m_UIFormHelper); m_InstancePool.Register(uiFormInstanceObject, true); m_UIFormsBeingLoaded.Remove(openUIFormInfo.SerialId); m_UIFormAssetNamesBeingLoaded.Remove(uiFormAssetName); if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId)) { Log.Debug("Release UI form '{0}' on loading success.", openUIFormInfo.SerialId.ToString()); m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId); m_UIFormHelper.ReleaseUIForm(uiFormAsset, null); return; } InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData); }
/// <summary> /// 打开界面。 /// </summary> /// <param name="uiFormTypeId">界面类型编号。</param> /// <param name="uiFormAssetName">界面资源名称。</param> /// <param name="uiGroupName">界面组名称。</param> /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param> /// <param name="userData">用户自定义数据。</param> public void OpenUIForm(int uiFormTypeId, string uiFormAssetName, string uiGroupName, bool pauseCoveredUIForm, object userData) { if (m_ResourceManager == null) { throw new GameFrameworkException("You must set resource manager first."); } if (m_UIFormHelper == null) { throw new GameFrameworkException("You must set UI form helper first."); } UIGroup uiGroup = GetUIGroup(uiGroupName) as UIGroup; if (uiGroup == null) { throw new GameFrameworkException(string.Format("UI group '{0}' is not exist.", uiGroupName)); } UIFormInstanceObject uiFormInstanceObject = m_InstancePool.Spawn(uiFormAssetName); if (uiFormInstanceObject == null) { m_ResourceManager.InstantiateAsset(uiFormAssetName, m_InstantiateAssetCallbacks, new OpenUIFormInfo(uiFormTypeId, uiGroup, pauseCoveredUIForm, userData)); return; } InternalOpenUIForm(uiFormTypeId, uiFormAssetName, uiGroup, uiFormInstanceObject.Target, pauseCoveredUIForm, false, 0f, userData); }
/// <summary> /// 打开界面。 /// </summary> /// <param name="uiFormAssetName">界面资源名称。</param> /// <param name="uiGroupName">界面组名称。</param> /// <param name="uiGroupDepth">界面组深度</param> /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param> /// <param name="userData">用户自定义数据。</param> public void OpenUIForm(string uiFormAssetName, string uiGroupName, int uiGroupDepth, bool pauseCoveredUIForm, object userData) { Guard.Verify <ArgumentException>(m_UIFormHelper == null, "You must set UI form helper first."); Guard.NotEmptyOrNull(uiFormAssetName, "UI form asset name is invalid."); Guard.NotEmptyOrNull(uiGroupName, "UI group name is invalid."); UIGroup uiGroup = (UIGroup)GetUIGroup(uiGroupName); if (uiGroup == null) { uiGroup = (UIGroup)AddUIGroup(uiGroupName, uiGroupDepth); } if (HasUIForm(uiFormAssetName)) { return; } UIFormInstanceObject uiFormInstanceObject = m_InstancePool.Spawn(uiFormAssetName); if (uiFormInstanceObject == null) { // 把资源加载抽到这里,为后续异步加载资源与实例化分开处理 var uiFormInstance = m_UIFormHelper.InstantiateUIForm(ResourceUtils.Load(uiFormAssetName)); uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormInstance, m_UIFormHelper); m_InstancePool.Register(uiFormInstanceObject, true); InnerOpenUIForm(uiFormAssetName, uiGroup, uiFormInstanceObject.Target, pauseCoveredUIForm, true, userData); } else { InnerOpenUIForm(uiFormAssetName, uiGroup, uiFormInstanceObject.Target, pauseCoveredUIForm, false, userData); } }
private void InstantiateUIFormSuccessCallback(string uiFormAssetName, object uiFormInstance, float duration, object userData) { UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormInstance, m_UIFormHelper); m_InstancePool.Register(uiFormInstanceObject, true); OpenUIFormInfo openUIFormInfo = userData as OpenUIFormInfo; if (openUIFormInfo == null) { throw new GameFrameworkException("Open UI form info is invalid."); } InternalOpenUIForm(openUIFormInfo.UIFormTypeId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData); }
/// <summary> /// 打开界面。 /// </summary> /// <param name="uiFormAssetName">界面资源名称。</param> /// <param name="uiGroupName">界面组名称。</param> /// <param name="priority">加载界面资源的优先级。</param> /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>界面的序列编号。</returns> public int OpenUIForm(string uiFormAssetName, string uiGroupName, int priority, bool pauseCoveredUIForm, object userData) { if (m_ResourceManager == null) { throw new GameFrameworkException("You must set resource manager first."); } if (m_UIFormHelper == null) { throw new GameFrameworkException("You must set UI form helper first."); } if (string.IsNullOrEmpty(uiFormAssetName)) { throw new GameFrameworkException("UI form asset name is invalid."); } if (string.IsNullOrEmpty(uiGroupName)) { throw new GameFrameworkException("UI group name is invalid."); } UIGroup uiGroup = (UIGroup)GetUIGroup(uiGroupName); if (uiGroup == null) { throw new GameFrameworkException(string.Format("UI group '{0}' is not exist.", uiGroupName)); } int serialId = m_Serial++; UIFormInstanceObject uiFormInstanceObject = m_InstancePool.Spawn(uiFormAssetName); if (uiFormInstanceObject == null) { m_UIFormsBeingLoaded.Add(serialId); m_UIFormAssetNamesBeingLoaded.Add(uiFormAssetName); m_ResourceManager.LoadAsset(uiFormAssetName, priority, m_LoadAssetCallbacks, new OpenUIFormInfo(serialId, uiGroup, pauseCoveredUIForm, userData)); } else { InternalOpenUIForm(serialId, uiFormAssetName, uiGroup, uiFormInstanceObject.Target, pauseCoveredUIForm, false, 0f, userData); } return(serialId); }
public static UIFormInstanceObject Create(string name, object uiFormAsset, object uiFormInstance, IUIFormHelper uiFormHelper) { if (uiFormAsset == null) { throw new GameFrameworkException("UI form asset is invalid."); } if (uiFormHelper == null) { throw new GameFrameworkException("UI form helper is invalid."); } UIFormInstanceObject uiFormInstanceObject = ReferencePool.Acquire <UIFormInstanceObject>(); uiFormInstanceObject.Initialize(name, uiFormInstance); uiFormInstanceObject.m_UIFormAsset = uiFormAsset; uiFormInstanceObject.m_UIFormHelper = uiFormHelper; return(uiFormInstanceObject); }
private void LoadUIFormSuccessCallback(string uiFormAssetName, object uiFormAsset, float duration, object userData) { OpenUIForm openUIFormInfo = (OpenUIFormInfo)userData; m_UIFormBeingLoaded.Remove(openUIFormInfo.SerialId); m_UIFormAssetNamesBeingLoaded.Remove(uiFormAssetName); if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId)) { Log.Debug(); m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId); m_UIFormHelper.ReleaseUIForm(uiFormAsset, null); return; } UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormAsset, m_UIFormHelper.InstantiateUIForm(uiFormAsset), m_UiFormHelper); m_InstancePool.Register(uiFormInstanceObject, true); InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, uiFormInstanceObject.Target); }
public int OpenUIForm(string uiFormAssetName, string uiGroupName, object userData) { UIGroup uig = (UIGroup)GetUIGroup(name); int serialId = m_Serial++; UIFormInstanceObject uiFormInstanceObject = m_InstancePool.Spawn(uiFormAssetName); if (uiFormInstanceObject == null) { m_UIFormsBeingLoaded.Add(serialId); m_UIFormAssetNamesBeingLoaded.Add(uiFormAssetName); m_ResourceManager.LoadAsset(uiFormAssetName, m_LoadAssetCallback, new OpenUIFormInfo(serialId, uiGroupName, userData)); } else { InternalOpenUIForm(serialId, uiFormAssetName, uiGroupName, uiFormInstanceObject.Target); } return serialId; }