This commit is contained in:
2025-02-22 01:37:30 +08:00
parent 34367f433f
commit 30ca85748d
36 changed files with 2859 additions and 65 deletions
+53
View File
@@ -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);
}
}
}