Created
July 23, 2020 09:58
-
-
Save Nrjwolf/1ac404c3cba55cfc7fe1865d96f74c00 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 | |
} |
Author
Nrjwolf
commented
Jul 23, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment