-
-
Save asfdfdfd/d918c7b289736aa0c23c72efea203d81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using Nrjwolf.Tools.AttachAttributes; // https://github.com/Nrjwolf/unity-auto-attach-component-attributes | |
using TMPro; | |
using UnityEngine; | |
[RequireComponent(typeof(TextMeshProUGUI))] | |
public class TextMeshProTeletypeEffect : MonoBehaviour | |
{ | |
[GetComponent] [SerializeField] private TextMeshProUGUI m_TextMeshProUGUI; | |
public TextMeshProUGUI TextMeshProUGUI { get => m_TextMeshProUGUI; } | |
[Range(0, 1)] | |
[SerializeField] | |
private float m_Value = 1; | |
public float Value | |
{ | |
get => m_Value; | |
set | |
{ | |
m_Value = value; | |
TextMeshProUGUI.maxVisibleCharacters = (int)(TextMeshProUGUI.textInfo.characterCount * value); | |
} | |
} | |
#if UNITY_EDITOR | |
void OnValidate() | |
{ | |
if (!gameObject.activeInHierarchy) | |
return; | |
Value = m_Value; | |
} | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment