增加了messagebox显示的命令和功能,另外为对话暂停做了一些事件准备
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user