Example #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;
            }


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

            if (entity == null)
            {
                Debug.LogError(uiFormId + "    当前表不存在");
                return;
            }

#if DISABLE_ASSETBUNDLE && UNITY_EDITOR
            UIFormBase formBase = GameEntry.UI.Dequeue(uiFormId);
            if (formBase == null)
            {
                string assetString = string.Empty;
                switch (GameEntry.Localization.CurrLanguage)
                {
                case GameLanguage.Chinese:
                    assetString = entity.AssetPath_Chinese;
                    ; break;

                case GameLanguage.English:
                    assetString = entity.AssetPath_English;
                    ; break;

                default:
                    break;
                }


                string path = string.Format("Assets/Download/UI/UIPrefab/{0}.prefab", assetString);

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

                GameObject uiObj = Object.Instantiate(obj) as GameObject;
                uiObj.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);
            }

            m_OpenUIList.AddLast(formBase);
#endif
        }
Example #2
0
        /// <summary>
        /// 打开UI窗体
        /// </summary>
        /// <param name="uiFormId"></param>
        /// <param name="userData"></param>
        internal void OpenUIForm(int uiFormId, object userData = null)
        {
            if (IsExists(uiFormId))
            {
                return;
            }

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

            if (entity == null)
            {
                Debug.Log("对应的UI窗体数据不存在,id:" + uiFormId);
                return;
            }

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

            if (formBase == null)
            {
                //TODO:异步加载UI需要时间 过滤正在加载的UI

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

                case LocalizationComponent.LanguageEnum.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);
                });
            }
            else
            {
                formBase.gameObject.SetActive(true);
                formBase.Open(userData);
                m_OpenUIFormList.AddLast(formBase);
            }
        }
Example #3
0
        /// <summary>
        /// 打开ui窗口
        /// </summary>
        /// <param name="uiFormID">UI的对应id</param>
        /// <param name="userData">要传的数据</param>
        /// <param name="onOpen">回调</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)
            {
                Debug.Log(uiFormID + "对应的UI窗体不存在");
                return;
            }

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

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

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

                case TQLanguage.English:
                    assetPath = entity.AssetPath_English;
                    break;
                }
                LoadUIAsset(assetPath, (ResourceEntity resourceEntity) =>
                {
                    GameObject uiObj = UnityEngine.Object.Instantiate((UnityEngine.Object)resourceEntity.Target) as GameObject;
                    //把克隆出来的资源 加入实例资源池
                    GameEntry.Pool.RegisterInstanceResource(uiObj.GetInstanceID(), resourceEntity);
                    uiObj.transform.SetParent(GameEntry.UI.GetGroup(entity.UIGroupId).Group);
                    uiObj.transform.localPosition = Vector3.zero;
                    uiObj.transform.localScale    = Vector3.one;

                    RectTransform rect = uiObj.GetComponent <RectTransform>();
                    rect.offsetMax     = new Vector2(0, 0);
                    rect.offsetMin     = new Vector2(0, 0);
                    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);
                }
            }
        }