| | |
| | | public enum UILayer |
| | | { |
| | | Static, // 静态UI 适合做 战斗 主界面 |
| | | Bottom, // 主界面 |
| | | Mid, // 功能窗口 |
| | | System, // 网络弹窗/其他重要弹窗 |
| | | Bottom, // 部分界面特殊处理层级用 |
| | | Mid, // 大部分功能窗口都放这层,便于跳转上下层管理(一个界面可以同时存在多个) |
| | | System, // 网络弹窗,信息提示等,其他重要弹窗 |
| | | Loading, // 加载界面 |
| | | |
| | | } |
| | |
| | | [SerializeField] public UILayer uiLayer = UILayer.Mid; |
| | | [SerializeField][HideInInspector] public string uiName; |
| | | [SerializeField] public bool isMainUI = false; |
| | | [SerializeField] public bool supportParentChildRelation = true; // 新增:是否支持父子关系 |
| | | |
| | | // 新增:是否支持父子关系 |
| | | // 父子关系:UI拥有的上下级链式关系 |
| | | // 在非特定情况下 都要拥有父子关系 (一般来说功能都要有父子关系 例外的是例如系统弹窗 |
| | | // 主界面这种不需要 在制作UI伤 目前的需求是 功能全部做在Middle层) |
| | | // 拥有父子关系 在关闭父界面的时候 子界面会连同一起关闭 子界面打开时 父界面的“回合数”会刷新 回合数详见持久化相关的注释 |
| | | // |
| | | [SerializeField] public bool supportParentChildRelation = true; |
| | | |
| | | // 持久化相关 |
| | | [SerializeField] public bool isPersistent = false; |
| | |
| | | // 打开遮罩 |
| | | [SerializeField] public bool openMask = false; |
| | | |
| | | // 点击空白区域关闭界面 |
| | | // 默认点击空白区域关闭界面 |
| | | [SerializeField] public bool clickEmptySpaceClose = false; |
| | | |
| | | private GameObject screenMask = null; |
| | | |
| | | private Button btnClickEmptyClose; |
| | | public Action btnClickEmptyCloseEvent = null; //提供点击空白区域关闭界面的回调 |
| | | |
| | | // 跟OneLevelWin联动 实际上是需要继承自OneLevelWin才能生效的值 使用需要注意 |
| | | int m_FunctionOrder = 0; |
| | |
| | | //延迟创建会导致层级在ScreenMask之上 |
| | | GameObject goBtnESC = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ClickEmptyCloseMask"), transform); |
| | | btnClickEmptyClose = goBtnESC.GetComponent<Button>(); |
| | | btnClickEmptyClose.AddListener(CloseWindow); |
| | | btnClickEmptyClose.transform.SetAsFirstSibling(); |
| | | await UniTask.DelayFrame(5); |
| | | |
| | | btnClickEmptyClose = goBtnESC.GetComponent<Button>(); |
| | | btnClickEmptyClose.AddListener(CloseWindow); |
| | | btnClickEmptyClose.AddListener(()=> |
| | | { |
| | | if (btnClickEmptyCloseEvent != null) |
| | | { |
| | | btnClickEmptyCloseEvent(); |
| | | } |
| | | else |
| | | { |
| | | CloseWindow(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 设置Canvas属性 |
| | | canvas.overrideSorting = true; |
| | | |
| | | canvas.worldCamera = CameraManager.uiCamera; |
| | | |
| | | canvas.sortingLayerID = SortingLayer.NameToID("UI"); // 确保使用正确的排序层 |
| | | |
| | | // 获取或添加CanvasGroup组件 |
| | | canvasGroup = GetComponent<CanvasGroup>(); |
| | |
| | | /// <summary> |
| | | /// 播放UI特效 |
| | | /// </summary> |
| | | /// <param name="effectName">特效资源名称</param> |
| | | /// <param name="id">特效资源名称</param> |
| | | /// <param name="parent">特效父节点,默认为当前UI</param> |
| | | /// <param name="autoDestroy">是否自动销毁,默认为true</param> |
| | | /// <param name="destroyDelay">自动销毁延迟时间,默认为5秒</param> |
| | | /// <returns>特效游戏对象</returns> |
| | | public EffectPlayer PlayUIEffect(int id, Transform parent = null, bool autoDestroy = true, float destroyDelay = 5f) |
| | | public UIEffectPlayer PlayUIEffect(int id, Transform parent = null) |
| | | { |
| | | // 使用默认值 |
| | | if (parent == null) parent = transform; |
| | | |
| | | EffectPlayer player = parent.gameObject.AddComponent<EffectPlayer>(); |
| | | |
| | | player.effectId = id; |
| | | player.autoDestroy = autoDestroy; |
| | | player.destroyDelay = destroyDelay; |
| | | player.canvas = canvas; |
| | | |
| | | return player; |
| | | return UIEffectPlayer.CreateEffect(id, parent, false); |
| | | } |
| | | |
| | | #endregion |