using DG.Tweening; using System; using System.Collections; using TMPro; using UnityEngine; using UnityEngine.UI; public class UI_CustomSessionPanel : BasePanel { private string triggerID; public Action callBack; private TextMeshProUGUI UItext; private string fullText; private float typingSpeed = 0.05f; /// /// 初始化,state 0 激活另一个操作 /// public void Init(string triggerID, string clientTalk, Action _callBack) { this.triggerID = triggerID; callBack += _callBack; GetControl("ClientText_DialogBox").text = clientTalk /*"好的"*/; UItext.text = GetControl("ClientText_DialogBox").text; StartTypewriterEffect(); } //} /// /// 按钮点击 /// /// protected override void OnClick(string btnName) { switch (btnName) { case "ClientContinueBtn": //GameManager.UIMgr.HidePanel(); callBack?.Invoke(triggerID); break; } } void StartTypewriterEffect() { // 使用DoTween的DOText方法实现打字机效果 UItext.DOText(fullText, fullText.Length * typingSpeed) .SetEase(Ease.Linear); } }