Beispiel #1
0
        /// <summary>
        /// 打开UI窗体
        /// </summary>
        /// <param name="uiFormId"></param>
        /// <param name="userData"></param>
        internal void OpenUIForm(int uiFormId, object userData = null)
        {
            if (IsExists(uiFormId))
            {
                return;
            }
            //1.读表

            Sys_UIFormEntity entity = GameEntry.DataTable.DataTableManager.Sys_UIFormDBModel.Get(uiFormId);

            if (entity == null)
            {
                return;
            }
#if DISABLE_ASSETBUNDLE && UNITY_EDITOR
            UIFormBase formBase = GameEntry.UI.Dequeue(uiFormId);

            if (formBase == null)
            {
                string assetPath = string.Empty;
                switch (GameEntry.Localization.CurrLanguage)
                {
                case YouYouLanguage.Chinese:
                    assetPath = entity.AssetPath_Chinese;
                    break;

                case YouYouLanguage.English:
                    assetPath = entity.AssetPath_English;
                    break;
                }
                string path = string.Format("Assets/Download/UI/UIPrefab/{0}.prefab", assetPath);

                //加载镜像
                Object obj = UnityEditor.AssetDatabase.LoadAssetAtPath <GameObject>(path);

                GameObject uiObj = Object.Instantiate(obj) as GameObject;

                uiObj.transform.SetParent(GameEntry.UI.GetUIGroup(entity.UIGroupId).Group);
                uiObj.transform.localPosition = Vector3.zero;
                uiObj.transform.localScale    = Vector3.one;

                formBase = uiObj.GetComponent <UIFormBase>();
                formBase.Init(uiFormId, entity.UIGroupId, entity.DisableUILayer == 1, entity.IsLock == 1, userData);
            }
            else
            {
                formBase.gameObject.SetActive(true);
                formBase.Open(userData);
            }
#else
#endif
            m_OpenUIFormList.AddLast(formBase);
        }
Beispiel #2
0
        /// <summary>
        /// 打开UI窗体
        /// </summary>
        /// <param name="uiFormId">formId</param>
        /// <param name="userData"></param>
        internal void OpenUIForm(int uiFormId, object userData = null, BaseAction <UIFormBase> onOpen = null)
        {
            if (IsExists(uiFormId))
            {
                return;
            }

            //1.读表
            Sys_UIFormEntity entity = GameEntry.DataTable.DataTableManager.Sys_UIFormDBModel.Get(uiFormId);

            if (entity == null)
            {
                GameEntry.LogError(uiFormId + "对应的UI窗体不存在");
                return;
            }

            UIFormBase formBase = GameEntry.UI.Dequeue(uiFormId);

            if (formBase == null)
            {
                //TODO:异步加载UI需要时间 此处需要处理过滤加载中的UI

                string assetPath = string.Empty;
                switch (GameEntry.Localization.CurrLanguage)
                {
                case YouYouLanguage.Chinese:
                    assetPath = entity.AssetPath_Chinese;
                    break;

                case YouYouLanguage.English:
                    assetPath = entity.AssetPath_English;
                    break;
                }

                LoadUIAsset(assetPath, (ResourceEntity resourceEntity) =>
                {
                    GameObject uiObj = Object.Instantiate((Object)resourceEntity.Target) as GameObject;

                    //把克隆出来的资源 加入实例资源池
                    GameEntry.Pool.RegisterInstanceResource(uiObj.GetInstanceID(), resourceEntity);

                    uiObj.transform.SetParent(GameEntry.UI.GetUIGroup(entity.UIGroupId).Group);
                    uiObj.transform.localPosition = Vector3.zero;
                    uiObj.transform.localScale    = Vector3.one;

                    formBase = uiObj.GetComponent <UIFormBase>();
                    formBase.Init(uiFormId, entity.UIGroupId, entity.DisableUILayer == 1, entity.IsLock == 1, userData);
                    m_OpenUIFormList.AddLast(formBase);

                    if (onOpen != null)
                    {
                        onOpen(formBase);
                    }
                });
            }
            else
            {
                formBase.gameObject.SetActive(true);
                formBase.Open(userData);
                m_OpenUIFormList.AddLast(formBase);

                if (onOpen != null)
                {
                    onOpen(formBase);
                }
            }
        }