//------------------------------------------------------------ // Game Framework // Copyright © 2013-2021 loyalsoft. All rights reserved. // Homepage: http://www.game7000.com/ // Feedback: http://www.game7000.com/ //------------------------------------------------------------ using GameFramework; using GameFramework.Fsm; using UnityEditor; using UnityGameFramework.Runtime; namespace UnityGameFramework.Editor { [CustomEditor(typeof(FsmComponent))] internal sealed class FsmComponentInspector : GameFrameworkInspector { public override void OnInspectorGUI() { base.OnInspectorGUI(); if (!EditorApplication.isPlaying) { EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info); return; } FsmComponent t = (FsmComponent)target; if (IsPrefabInHierarchy(t.gameObject)) { EditorGUILayout.LabelField("FSM Count", t.Count.ToString()); FsmBase[] fsms = t.GetAllFsms(); foreach (FsmBase fsm in fsms) { DrawFsm(fsm); } } Repaint(); } private void OnEnable() { } private void DrawFsm(FsmBase fsm) { EditorGUILayout.LabelField(fsm.FullName, fsm.IsRunning ? Utility.Text.Format("{0}, {1} s", fsm.CurrentStateName, fsm.CurrentStateTime.ToString("F1")) : (fsm.IsDestroyed ? "Destroyed" : "Not Running")); } } }