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