/// <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]; }
/// <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); }
/// <summary> /// 设置层级 /// </summary> /// <param name="formBase"></param> /// <param name="isAdd"></param> internal void SetSortingOrder(UIFormBase formBase, bool isAdd) { ushort value = 0; if (m_UILayerDic.TryGetValue(formBase.GroupId, out value)) { if (isAdd) { m_UILayerDic[formBase.GroupId] += 10; } else { m_UILayerDic[formBase.GroupId] -= 10; } formBase.CurrCanvas.sortingOrder = m_UILayerDic[formBase.GroupId]; } }
/// <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); }
public void CloseUIForm(UIFormBase formBase) { m_UIManager.CloseUIForm(formBase); }
internal void CloseUIForm(UIFormBase formBase) { m_OpenUIFormList.Remove(formBase); formBase.ToClose(); }
/// <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); } } }