Initial commit

This commit is contained in:
2024-08-11 14:32:14 +08:00
commit 3c0c311dab
979 changed files with 114044 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
using Febucci.UI;
using Febucci.UI.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace AibisDream
{
public class DialogUiViewer : Singleton<DialogUiViewer>
{
#region UI
private GameObject dialogBox;
private TypewriterByCharacter dialogText;
private TextMeshProUGUI actorName;
private Button nextButton;
#endregion
private Action nextStepAction;
private void Start()
{
// 获取子物体
dialogBox = transform.GetChild(0).gameObject;
GetDialogComponentInBox(dialogBox);
}
/// <summary>
/// 显示文字
/// </summary>
/// <param name="dialogLine">对话内容</param>
/// <param name="actor">名称</param>
/// <param name="nextStep">下一步</param>
public void ShowLine(string dialogLine, string actor, Action nextStep)
{
dialogBox.SetActive(true);
actorName.text = actor;
dialogText.ShowText(dialogLine);
nextStepAction = nextStep;
}
public void ShowNextButton()
{
nextButton.gameObject.SetActive(true);
}
public void ClickNextStep()
{
Action temp = nextStepAction;
nextStepAction = null;
temp?.Invoke();
nextButton.gameObject.SetActive(false);
}
private void GetDialogComponentInBox(GameObject box)
{
actorName = box.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
dialogText = box.transform.GetChild(1).gameObject.GetComponent<TypewriterByCharacter>();
nextButton = box.transform.GetChild(2).GetComponent<Button>();
dialogText.onTextShowed.AddListener(ShowNextButton);
nextButton.onClick.AddListener(ClickNextStep);
}
public void HideDialog()
{
dialogBox?.SetActive(false);
}
}
}