KaiClavier

STMJumper.cs

Aug 29th, 2019 (edited)
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. //Copyright (c) 2019-2021 Kai Clavier [kaiclavier.com] Do Not Distribute
  2. using UnityEngine;
  3. using System.Collections;
  4. using UnityEngine.Events;
  5. using Fleece;
  6.  
  7. [ExecuteInEditMode] //this is needed for OnValidate to work
  8. public class STMJumper : MonoBehaviour, IJumperValidateable
  9. {
  10.    
  11.     private SuperTextMesh stm;
  12.     public Jumper jumper;
  13.    
  14.     void Awake()
  15.     {
  16.         stm = GetComponent<SuperTextMesh>();
  17.     }
  18.     public void OnEnable()
  19.     {
  20.         ValidateJumper();
  21.     }
  22.     private bool validate = false;
  23.     public void OnValidate()
  24.     {
  25.         validate = true;
  26.     }
  27.     public void Update()
  28.     {
  29.         if(!Application.isPlaying && validate)
  30.         {
  31.             validate = false;
  32.             ValidateJumper();
  33.         }
  34.     }
  35.     public void ValidateJumper()
  36.     {
  37.         if(jumper != null && jumper.passage != null && stm != null)
  38.         {
  39.             stm.text = jumper.passage.parsedText;
  40.         }
  41.     }
  42.    
  43. }
Add Comment
Please, Sign In to add comment