Files
aibis-dream/Assets/Scripts/FixSystem/Screen/MessageBox.cs
T

43 lines
956 B
C#

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);
}
}
}