增加了messagebox显示的命令和功能,另外为对话暂停做了一些事件准备

This commit is contained in:
2024-08-25 17:08:53 +08:00
parent 768064fb6f
commit a2bc181a11
7 changed files with 385 additions and 17 deletions
@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Yarn.Unity;
public class MessageBox : MonoBehaviour
{
public TMP_Text messageText; // Unity UI Text component
public void SetWarning(string message)
{
messageText.color = Color.red; // Set text color to red for warnings
messageText.text = message;
}
public void SetNormal(string message)
{
messageText.color = Color.black; // Set text color to black for normal messages
messageText.text = message;
}
[YarnCommand("messagebox")]
public void HandleMessageBoxCommand(string type,string text)
{
// 根据消息类型调用相应的方法
if (type == "warning")
{
SetWarning(text);
}
else if (type == "normal")
{
SetNormal(text);
}
else
{
Debug.LogError("Invalid message type for messagebox command: " + type);
}
}
}