Пример #1
0
        public static int?OpenHotUIForm(this UIComponent uiComponent, int uiFormId, string hotFormTypeName, object userData = null)
        {
            //先获取UI配置表数据
            IDataTable <DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable <DRUIForm>();
            DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);

            if (drUIForm == null)
            {
                return(null);
            }

            //获取资源路径
            string assetName = RuntimeAssetUtility.GetUIFormAsset(drUIForm.AssetName);

            if (!drUIForm.AllowMultiInstance)               //不允许存在多个界面实例
            {
                if (uiComponent.IsLoadingUIForm(assetName)) //正在加载
                {
                    return(null);
                }

                UIForm uiForm = uiComponent.GetUIForm(assetName);   //获取已加载的界面
                if (uiForm != null)
                {
                    return(uiForm.SerialId); //TODO:这里返回已打开界面id?还是返回null?
                }
            }

            //UI传递的数据
            //UserUIData uiData = ReferencePool.Acquire<UserUIData>();
            //uiData.Fill(hotFormTypeName, userData);
            UserUIData uiData = new UserUIData(hotFormTypeName, userData);

            return(uiComponent.OpenUIForm(assetName, drUIForm.UIGroupName, RuntimeConstant.AssetPriority.UIFormAsset, drUIForm.PauseCoveredUIForm, uiData));
        }
Пример #2
0
        //界面打开
        protected override void OnOpen(object userData)
        {
            base.OnOpen(userData);

            UserUIData data = userData as UserUIData;   //临时缓存,避免下面ReleaseLogicData时Release

            if (UserUIData != data)
            {
                data.RuntimeUIForm = this;
                if (data.HotLogicTypeFullName != HotLogicScript) //检查逻辑类名是否一样
                {
                    ReleaseLogicData();                          //释放保存的Hot逻辑
                    InitLogicData(data);                         //重新初始化Hot逻辑,并调用Init方法
                }

                UserUIData = data;
            }

            if (OnOpenMethod.IsAvalible)
            {
                OnOpenMethod.Run(UserUIData.UserData);
            }
        }
Пример #3
0
        //初始化逻辑数据
        private void InitLogicData(UserUIData data)
        {
            HotLogicInstance = GameEntry.Hotfix.CreateInstance(UserUIData.HotLogicTypeFullName, null);  //创建实例
            HotLogicScript   = UserUIData.HotLogicTypeFullName;

#if ILRuntime
            //获取方法
            OnInitMethod         = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnInit", 1);
            OnOpenMethod         = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnOpen", 1);
            OnUpdateMethod       = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnUpdate", 0);
            OnRefocusMethod      = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnRefocus", 1);
            OnResumeMethod       = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnResume", 0);
            OnPauseMethod        = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnPause", 0);
            OnCoverMethod        = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnCover", 0);
            OnRevealMethod       = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnReveal", 0);
            OnCloseMethod        = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnClose", 1);
            OnDepthChangedMethod = ReferencePool.Acquire <ILInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnDepthChanged", 2);
#else
            //获取方法
            OnInitMethod         = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnInit");
            OnOpenMethod         = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnOpen");
            OnUpdateMethod       = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnUpdate");
            OnRefocusMethod      = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnRefocus");
            OnResumeMethod       = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnResume");
            OnPauseMethod        = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnPause");
            OnCoverMethod        = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnCover");
            OnRevealMethod       = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnReveal");
            OnCloseMethod        = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnClose");
            OnDepthChangedMethod = ReferencePool.Acquire <ReflectInstanceMethod>().Fill(HotLogicInstance, UserUIData.HotLogicTypeFullName, "OnDepthChanged");
#endif

            if (OnInitMethod.IsAvalible)
            {
                OnInitMethod.Run(UserUIData);
            }
        }