private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData) { try { IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData); if (uiForm == null) { throw new GameFrameworkException("Can not create UI form in helper."); } uiForm.OnInit(serialId, uiFormAssetName, uiGroup, pauseCoveredUIForm, isNewInstance, userData); uiGroup.AddUIForm(uiForm); uiForm.OnOpen(userData); uiGroup.Refresh(); if (m_OpenUIFormSuccessEventHandler != null) { OpenUIFormSuccessEventArgs openUIFormSuccessEventArgs = OpenUIFormSuccessEventArgs.Create(uiForm, duration, userData); m_OpenUIFormSuccessEventHandler(this, openUIFormSuccessEventArgs); ReferencePool.Release(openUIFormSuccessEventArgs); } } catch (Exception exception) { if (m_OpenUIFormFailureEventHandler != null) { OpenUIFormFailureEventArgs openUIFormFailureEventArgs = OpenUIFormFailureEventArgs.Create(serialId, uiFormAssetName, uiGroup.Name, pauseCoveredUIForm, exception.ToString(), userData); m_OpenUIFormFailureEventHandler(this, openUIFormFailureEventArgs); ReferencePool.Release(openUIFormFailureEventArgs); return; } throw; } }
private void LoadUIFormFailureCallback(string uiFormAssetName, LoadResourceStatus status, string errorMessage, 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); return; } m_UIFormsBeingLoaded.Remove(openUIFormInfo.SerialId); string appendErrorMessage = Utility.Text.Format("Load UI form failure, asset name '{0}', status '{1}', error message '{2}'.", uiFormAssetName, status.ToString(), errorMessage); if (m_OpenUIFormFailureEventHandler != null) { OpenUIFormFailureEventArgs openUIFormFailureEventArgs = OpenUIFormFailureEventArgs.Create(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup.Name, openUIFormInfo.PauseCoveredUIForm, appendErrorMessage, openUIFormInfo.UserData); m_OpenUIFormFailureEventHandler(this, openUIFormFailureEventArgs); ReferencePool.Release(openUIFormFailureEventArgs); ReferencePool.Release(openUIFormInfo); return; } ReferencePool.Release(openUIFormInfo); throw new GameFrameworkException(appendErrorMessage); }
private void OnOpenUIFormFailure(object sender, GameFramework.UI.OpenUIFormFailureEventArgs e) { Log.Warning("Open UI form failure, asset name '{0}', UI group name '{1}', pause covered UI form '{2}', error message '{3}'.", e.UIFormAssetName, e.UIGroupName, e.PauseCoveredUIForm.ToString(), e.ErrorMessage); if (m_EnableOpenUIFormFailureEvent) { m_EventComponent.Fire(this, new OpenUIFormFailureEventArgs(e)); } }