From fc8ca4e6ba003fdf1c7d8466cd4bf800179eb1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A3=AE2003?= <2384017988@qq.com> Date: Fri, 10 Jul 2026 20:01:07 +0800 Subject: [PATCH] 1 --- .../MyGame/aa/UI/DefaultPanel/TiShi/TiShi.cs | 35 +++++++++++++++++-- .../Sub/UIHome_BY_SelectRoomLevelPanel.cs | 32 ++++++++++++++--- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/Assets/MyGame/aa/UI/DefaultPanel/TiShi/TiShi.cs b/Assets/MyGame/aa/UI/DefaultPanel/TiShi/TiShi.cs index 76a68ec80..5e0aed783 100644 --- a/Assets/MyGame/aa/UI/DefaultPanel/TiShi/TiShi.cs +++ b/Assets/MyGame/aa/UI/DefaultPanel/TiShi/TiShi.cs @@ -1,4 +1,5 @@ using System; +using DG.Tweening; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -11,8 +12,12 @@ public class TiShi : MonoBehaviour public Action action; + private Vector3 _standardSize; + private bool _closing; + private void Awake() { + _standardSize = transform.GetChild(0).localScale; if (btn_Close != null) btn_Close.onClick.AddListener(Close); if (btn_QueRen != null) @@ -20,7 +25,7 @@ public class TiShi : MonoBehaviour } /// - /// 初始化提示文字。 + /// 初始化提示文字,并播放弹窗出现动画。 /// /// 提示内容 /// 点击确认按钮时的回调(可选) @@ -29,18 +34,42 @@ public class TiShi : MonoBehaviour action = onConfirmAction; if (tmpText_TiShiLabel != null) tmpText_TiShiLabel.text = text; + PlayAppear(); + } + + private void PlayAppear() + { + var t = transform.GetChild(0); + t.localScale = Vector3.zero; + t.DOKill(); + t.DOScale(_standardSize, 0.55f).SetEase(Ease.OutElastic, 0.7f, 0.35f); } /// 确认按钮:触发回调后关闭 public void Confirm() { + if (_closing) return; + _closing = true; action?.Invoke(); - Destroy(gameObject); + PlayHideThenDestroy(); } /// 关闭按钮:直接关闭,不触发回调 public void Close() { - Destroy(gameObject); + if (_closing) return; + _closing = true; + PlayHideThenDestroy(); + } + + private void PlayHideThenDestroy() + { + var t = transform.GetChild(0); + t.DOKill(); + t.DOScale(0, 0.3f).SetEase(Ease.InBack).onComplete += () => + { + if (this != null && gameObject != null) + Destroy(gameObject); + }; } } diff --git a/Assets/MyGame/aa/UI/Home/Sub/UIHome_BY_SelectRoomLevelPanel.cs b/Assets/MyGame/aa/UI/Home/Sub/UIHome_BY_SelectRoomLevelPanel.cs index b054586ff..796e15b22 100644 --- a/Assets/MyGame/aa/UI/Home/Sub/UIHome_BY_SelectRoomLevelPanel.cs +++ b/Assets/MyGame/aa/UI/Home/Sub/UIHome_BY_SelectRoomLevelPanel.cs @@ -3,6 +3,7 @@ using Assets.MyGame.Scripts.Net.WebResponses; using System; using System.Collections; using System.Collections.Generic; +using DG.Tweening; using TMPro; using UnityEngine; using UnityEngine.Rendering.Universal; @@ -44,6 +45,7 @@ public class UIHome_BY_SelectRoomLevelPanel : SubUIBase public Button btn_CloseTiShi; public Button btn_QuXiao; public Button btn_ChongZhi; + private Vector3 _tiShiStandardSize; /// 检查当前用户是否有手动选座权限 private bool CanSelectRoom() @@ -69,26 +71,46 @@ public class UIHome_BY_SelectRoomLevelPanel : SubUIBase WebSocketManager.Instance.Connect(SocketType.room); // 提示窗口:确认/关闭效果一致(关闭提示),充值跳转商城 - if (tiShi != null) tiShi.SetActive(false); + if (tiShi != null) + { + tiShi.SetActive(false); + _tiShiStandardSize = tiShi.transform.GetChild(0).localScale; + } if (btn_CloseTiShi != null) - btn_CloseTiShi.onClick.AddListener(() => { if (tiShi != null) tiShi.SetActive(false); }); + btn_CloseTiShi.onClick.AddListener(HideTiShi); if (btn_QuXiao != null) - btn_QuXiao.onClick.AddListener(() => { if (tiShi != null) tiShi.SetActive(false); }); + btn_QuXiao.onClick.AddListener(HideTiShi); if (btn_ChongZhi != null) btn_ChongZhi.onClick.AddListener(() => { - if (tiShi != null) tiShi.SetActive(false); + HideTiShi(); UIManager.Instance.Get(UIPanel.HomeMainPanel) .subUIManager.ShowAsync(UIPanel.ShopPanel, ShopTab.Diamond); }); } - /// 显示提示窗口(手动选座需要充值VIP等) + /// 显示提示窗口(弹窗出现动画) private void ShowTiShi(string msg) { if (tiShi == null) return; if (tmpText_Label != null) tmpText_Label.text = msg; tiShi.SetActive(true); + var t = tiShi.transform.GetChild(0); + t.localScale = Vector3.zero; + t.DOKill(); + t.DOScale(_tiShiStandardSize, 0.55f).SetEase(Ease.OutElastic, 0.7f, 0.35f); + } + + /// 隐藏提示窗口(缩放消失动画) + private void HideTiShi() + { + if (tiShi == null || !tiShi.activeSelf) return; + var t = tiShi.transform.GetChild(0); + t.DOKill(); + t.DOScale(0, 0.3f).SetEase(Ease.InBack).onComplete += () => + { + if (tiShi != null) tiShi.SetActive(false); + }; } public void OnSelectRoom(int leave) {