/// <summary> /// 打开UI界面(使用带枚举参数的方法) /// </summary> /// <param name="uiComponent">UI组件</param> /// <param name="uiFormId">界面编号</param> /// <param name="userData"></param> /// <returns></returns> public static int?OpenUIForm(this UIComponent uiComponent, int uiFormId, object userData = null) { IDataTable <DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable <DRUIForm>(); DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId); if (drUIForm == null) { Log.Warning("Can not load UI form '{0}' from data table.", uiFormId.ToString()); return(null); } string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName); if (!drUIForm.AllowMultiInstance) { if (uiComponent.IsLoadingUIForm(assetName)) { return(null); } if (uiComponent.HasUIForm(assetName)) { return(null); } } return(uiComponent.OpenUIForm(assetName, drUIForm.UIGroupName, Constant.AssetPriority.UIFormAsset, drUIForm.PauseCoveredUIForm, userData)); }
/// <summary> /// 是否存在指定UI界面(使用带枚举参数的方法) /// </summary> /// <param name="uiComponent">UI组件</param> /// <param name="uiFormId">UI界面编号</param> /// <param name="uiGroupName">UI界面组名称</param> /// <returns></returns> public static bool HasUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null) { IDataTable <DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable <DRUIForm>(); DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId); if (drUIForm == null) { return(false); } string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName); if (string.IsNullOrEmpty(uiGroupName)) { return(uiComponent.HasUIForm(assetName)); } IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName); if (uiGroup == null) { return(false); } return(uiGroup.HasUIForm(assetName)); }
/// <summary> /// 获取UI界面对象(使用带枚举参数的方法) /// </summary> /// <param name="uiComponent">UI组件</param> /// <param name="uiFormId">UI界面编号</param> /// <param name="uiGroupName">UI界面组名称</param> /// <returns></returns> public static UGuiForm GetUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null) { IDataTable <DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable <DRUIForm>(); DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId); if (drUIForm == null) { return(null); } string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName); UIForm uiForm = null; if (string.IsNullOrEmpty(uiGroupName)) { uiForm = uiComponent.GetUIForm(assetName); if (uiForm == null) { return(null); } return((UGuiForm)uiForm.Logic); } IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName); if (uiGroup == null) { return(null); } uiForm = (UIForm)uiGroup.GetUIForm(assetName); if (uiForm == null) { return(null); } return((UGuiForm)uiForm.Logic); }