Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- [ExecuteInEditMode]
- [RequireComponent(typeof(SuperTextMesh))]
- /*
- at the moment I don't have a boolean to force STM to update so...
- create a new jitter that does nothing (set strength to 0)
- and include it at the start of strings to make STM force-update every frame.
- this script isn't needed anymore for STM v1.11+! The default color value is animateable and there's a boolean to force text to update every frame.
- */
- public class STMColorAnimationReceiver : MonoBehaviour
- {
- [SerializeField] private Color _color = Color.white;
- public Color color
- {
- get
- {
- return _color;
- }
- set
- {
- SetColor(value);
- }
- }
- public void SetColor(Color col)
- {
- _color = col;
- superTextMesh.color = _color;
- //superTextMesh.SetMesh(0f);// this isn't public... (hey, make this public!)
- //superTextMesh.Rebuild(); //this is too heavy...
- //mesh could also just have a wave that does nothing to force a SetMesh() call
- //maybe I'll add a "force animation" boolean? whatever
- //any of these options work but for now... use the note at the top of this script!
- }
- public SuperTextMesh superTextMesh;
- public void OnValidate()
- {
- validate = true;
- }
- private bool validate = false;
- public void Update()
- {
- if(validate)
- {
- SetColor(_color);
- }
- }
- public void Reset()
- {
- superTextMesh = GetComponent<SuperTextMesh>();
- }
- }
RAW Paste Data