From 0c3a0519a0f526fd67ac3df22fe801c51a81c5e7 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期五, 30 五月 2025 17:06:09 +0800 Subject: [PATCH] 18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建 --- Main/UI/UIBase.cs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/Main/UI/UIBase.cs b/Main/UI/UIBase.cs index 79f73fd..7e0e1eb 100644 --- a/Main/UI/UIBase.cs +++ b/Main/UI/UIBase.cs @@ -4,6 +4,7 @@ using DG.Tweening; using UnityEngine.UI; // DOTween 鎻掍欢寮曠敤 using Cysharp.Threading.Tasks; +using System; public enum UILayer { @@ -55,6 +56,18 @@ // 瀛怳I绠$悊 [HideInInspector] public List<UIBase> childrenUI = new List<UIBase>(); + // 鎵撳紑閬僵 + [SerializeField] public bool openMask = false; + + // 鐐瑰嚮绌虹櫧鍖哄煙鍏抽棴鐣岄潰 + [SerializeField] public bool clickEmptySpaceClose = false; + + private GameObject screenMask = null; + + private Button btnClickEmptyClose; + + protected int functionOrder = 0; + // 鍐呴儴鐘舵�� protected bool isActive = false; protected bool isAnimating = false; @@ -88,6 +101,16 @@ originalScale = rectTransform.localScale; originalPosition = rectTransform.anchoredPosition; } + + ApplySettings(); + + if (openMask) + { + screenMask = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ScreenMask"), transform); + screenMask.transform.localScale = Vector3.one; + screenMask.transform.localPosition = Vector3.zero; + screenMask.transform.SetAsFirstSibling(); + } } protected virtual void Start() @@ -95,6 +118,29 @@ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栧垵濮嬪寲 } + protected async UniTask ApplySettings() + { + await UniTask.DelayFrame(5); + + if (null != transform) + { + if (clickEmptySpaceClose) + { + GameObject goBtnESC = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ClickEmptyCloseMask"), transform); + // Load + btnClickEmptyClose = goBtnESC.GetComponent<Button>(); + btnClickEmptyClose.AddListener(CloseWindow); + btnClickEmptyClose.transform.SetAsFirstSibling(); + } + } + } + + protected async void ExecuteNextFrame(Action _action) + { + await UniTask.DelayFrame(1); + _action?.Invoke(); + } + protected virtual void OnDestroy() { // 纭繚鍔ㄧ敾琚纭竻鐞� -- Gitblit v1.8.0