Exemplo n.º 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.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);
            }
        }
 /// <summary>
 /// 设置层级
 /// </summary>
 /// <param name="formBase"></param>
 /// <param name="isAdd"></param>
 internal void SetSortingOrder(UIFormBase formBase, bool isAdd)
 {
     if (isAdd)
     {
         m_UILayerDic[formBase.GroupId] += 10;
     }
     else
     {
         m_UILayerDic[formBase.GroupId] -= 10;
     }
     formBase.CurrCanvas.sortingOrder = m_UILayerDic[formBase.GroupId];
 }
Exemplo n.º 3
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;
            }

#if DISABLE_ASSETBUNDLE && UNITY_EDITOR
            UIFormBase formBase = GameEntry.UI.Dequeue(uiFormId);

            if (formBase == null)
            {
                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;
                }
                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);
            }
#endif
            m_OpenUIFormList.AddLast(formBase);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 关闭UI窗体(根据UIFormBase)
 /// </summary>
 /// <param name="formBase"></param>
 internal void CloseUIForm(UIFormBase formBase)
 {
     m_OpenUIFormList.Remove(formBase);
     formBase.ToClose();
 }
 /// <summary>
 /// UI回池
 /// </summary>
 /// <param name="form"></param>
 internal void Enqueue(UIFormBase form)
 {
     form.gameObject.SetActive(false);
     m_UIFormList.AddLast(form);
 }
 /// <summary>
 /// UI回池
 /// </summary>
 /// <param name="form"></param>
 public void Enqueue(UIFormBase form)
 {
     m_UIPool.Enqueue(form);
 }
 /// <summary>
 /// 设置层级
 /// </summary>
 /// <param name="formBase"></param>
 /// <param name="isAdd"></param>
 public void SetSortingOrder(UIFormBase formBase, bool isAdd)
 {
     m_UILayer.SetSortingOrder(formBase, isAdd);
 }
 /// <summary>
 /// 关闭UI窗体(根据UIFormBase)
 /// </summary>
 /// <param name="formBase"></param>
 public void CloseUIForm(UIFormBase formBase)
 {
     m_UIManager.CloseUIForm(formBase);
 }