气泡
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.Utility;
|
||||
using Febucci.UI.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.Framework
|
||||
{
|
||||
public class TextBubble : MonoBehaviour
|
||||
{
|
||||
private TypewriterCore _typewriter;
|
||||
|
||||
#region 参数
|
||||
|
||||
[SerializeField] public ActorRole role;
|
||||
[SerializeField] private int maxCharNum;
|
||||
|
||||
#endregion
|
||||
|
||||
private bool _skipLineDelay;
|
||||
|
||||
public bool IsShowingText => _typewriter.isShowingText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_typewriter = GetComponentInChildren<TypewriterCore>();
|
||||
}
|
||||
|
||||
public void ShowLine(string line, Action onTextEnd)
|
||||
{
|
||||
_typewriter.ShowText("");
|
||||
gameObject.SetActive(true);
|
||||
var formattedLine = CommonUtil.SplitString(line, maxCharNum);
|
||||
_typewriter.ShowText(formattedLine);
|
||||
// 对话结束回调
|
||||
_typewriter.onTextShowed.RemoveAllListeners();
|
||||
_typewriter.onTextShowed.AddListener(() => onTextEnd?.Invoke());
|
||||
}
|
||||
|
||||
public void SkipLine()
|
||||
{
|
||||
if (_typewriter.isShowingText)
|
||||
{
|
||||
_typewriter.SkipTypewriter();
|
||||
}
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user