aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-06-01 15:09:59 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-06-01 15:09:59 +0800
commite63c8557b3b860f0d1d1dcea69816fca35ebc6a6 (patch)
tree328d6f684157b0b2957caf10e891b7a8035556e5 /Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs
parentcd6a2e619b80fe88279388470ebd4ea7e2fe5b3a (diff)
增加单向门
Diffstat (limited to 'Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs')
-rw-r--r--Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs
new file mode 100644
index 0000000..6680dee
--- /dev/null
+++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs
@@ -0,0 +1,41 @@
+using System;
+using UnityEngine;
+using TMPro;
+
+namespace SoulCoreGameLoop.UI
+{
+ [RequireComponent(typeof(Animator))]
+ public class MessageBox : MonoBehaviour, IUIEventSender<Message>
+ {
+ private static readonly int TriggerPlay = Animator.StringToHash("Play");
+
+ public TMP_Text messageText;
+ private Animator _animator;
+
+ private void Awake()
+ {
+ _animator = GetComponent<Animator>();
+ UIEventListener.Register(this);
+ }
+
+ private void OnDestroy()
+ => UIEventListener.Unregister<Message>();
+
+
+ public void OnReceive(Message evt)
+ {
+ messageText.text = evt.MessageText;
+ _animator.SetTrigger(TriggerPlay);
+ }
+ }
+
+ public struct Message
+ {
+ public readonly string MessageText;
+
+ public Message(string messageText)
+ {
+ MessageText = messageText;
+ }
+ }
+} \ No newline at end of file