Advertisement
TheLowestAnimal

Visual State Debugger

May 23rd, 2022
627
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using TMPro;
  6. using StateMachineLib;
  7.  
  8. [RequireComponent(typeof(StateMachineLib.StateMachine))]
  9. public class VisualStateDebugger : MonoBehaviour
  10. {
  11.     [SerializeField] private StateMachine _smManager;
  12.     [SerializeField] private TextMeshPro _stateDebugText;
  13.  
  14.     private void Awake()
  15.     {
  16.     }
  17.     private void Start()
  18.     {
  19.     }
  20.  
  21.     private void OnEnable()
  22.     {
  23.         if (_smManager)
  24.         _smManager._stateChanged += UpdateDisplay;
  25.     }
  26.  
  27.     private void OnDisable()
  28.     {
  29.         _smManager._stateChanged -= UpdateDisplay;
  30.     }
  31.  
  32.     private void UpdateDisplay()
  33.     {
  34.         Debug.LogError("State Has Changed!");
  35.         _stateDebugText.text = _smManager._currentState.GetType().ToString();
  36.  
  37.     }
  38. }
  39.  
Advertisement
RAW Paste Data Copied
Advertisement