feature: Messages are now animated
This commit is contained in:
parent
1c8fbc94e0
commit
923b7b6f62
6 changed files with 83 additions and 8 deletions
|
@ -1,20 +1,33 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Utilities;
|
||||
|
||||
namespace Messaging {
|
||||
public class Message : MonoBehaviour{
|
||||
public class Message : MonoBehaviour {
|
||||
public RectTransform RectTransform { private set; get; }
|
||||
public string Text => messageText.text;
|
||||
|
||||
[SerializeField] private TMP_Text messageText;
|
||||
|
||||
private TextTyper _textTyper;
|
||||
private Coroutine _typingCoroutine;
|
||||
|
||||
private void Awake() {
|
||||
RectTransform = GetComponent<RectTransform>();
|
||||
_textTyper = new TextTyper(messageText);
|
||||
}
|
||||
|
||||
public void SetMessageText(string text) {
|
||||
messageText.text = text;
|
||||
public void SetMessageText(string text, bool animate) {
|
||||
if (_textTyper.IsMessageAnimating()) {
|
||||
_textTyper.SkipToEndOfCurrentMessage();
|
||||
}
|
||||
this.EnsureCoroutineStopped(ref _typingCoroutine);
|
||||
|
||||
if (animate)
|
||||
_typingCoroutine = StartCoroutine(_textTyper.AnimateTextIn(text, null));
|
||||
else
|
||||
messageText.text = text;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue