KaiClavier

STMPreParseEffect.cs

Mar 26th, 2020
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Copyright (c) 2020 Kai Clavier [kaiclavier.com] Do Not Distribute
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. [RequireComponent(typeof(SuperTextMesh))]
  6. public class STMPreParseEffect : MonoBehaviour
  7. {
  8.  
  9.     public SuperTextMesh superTextMesh;
  10.     public string colorName = "rainbow";
  11.  
  12.     void Reset()
  13.     {
  14.         superTextMesh = GetComponent<SuperTextMesh>();
  15.     }
  16.  
  17.     void OnEnable()
  18.     {
  19.         superTextMesh.OnPreParse += AddTag;
  20.     }
  21.     void OnDisable()
  22.     {
  23.         superTextMesh.OnPreParse -= AddTag;
  24.     }
  25.     void AddTag(STMTextContainer container)
  26.     {
  27.         //add tag to start of container text
  28.         container.text = "<c=" + colorName + ">" + container.text;
  29.     }
  30. }
RAW Paste Data