This commit is contained in:
2026-07-10 20:01:07 +08:00
parent 5b89a0ccc4
commit fc8ca4e6ba
2 changed files with 59 additions and 8 deletions
@@ -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
}
/// <summary>
/// 初始化提示文字。
/// 初始化提示文字,并播放弹窗出现动画。
/// </summary>
/// <param name="text">提示内容</param>
/// <param name="onConfirmAction">点击确认按钮时的回调(可选)</param>
@@ -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);
}
/// <summary>确认按钮:触发回调后关闭</summary>
public void Confirm()
{
if (_closing) return;
_closing = true;
action?.Invoke();
Destroy(gameObject);
PlayHideThenDestroy();
}
/// <summary>关闭按钮:直接关闭,不触发回调</summary>
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);
};
}
}
@@ -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;
/// <summary>检查当前用户是否有手动选座权限</summary>
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<UIHomeMain>(UIPanel.HomeMainPanel)
.subUIManager.ShowAsync(UIPanel.ShopPanel, ShopTab.Diamond);
});
}
/// <summary>显示提示窗口(手动选座需要充值VIP等)</summary>
/// <summary>显示提示窗口(弹窗出现动画)</summary>
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);
}
/// <summary>隐藏提示窗口(缩放消失动画)</summary>
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)
{