public override void OnInspectorGUI() { LogicObject lo = (LogicObject)target; if (EditorApplication.isPlaying) { if (!lo.ShowAttrs && GUILayout.Button("ShowAttributes")) { lo.ShowAttrs = true; } if (lo.ShowAttrs && GUILayout.Button("HideAttributes")) { lo.ShowAttrs = false; } } serializedObject.Update(); GUI.enabled = !EditorApplication.isPlaying; GUI.color = Color.white; serializedObject.ApplyModifiedProperties(); var agent = lo.so.GetComponent <AIAgent>(); if (agent != null) { BTAsset btAsset = agent.BehaviourTree as BTAsset; BehaviourTree btInstance = agent.GetBehaviourTree(); GUI.enabled = btAsset != null; if (EditorApplication.isPlaying && btInstance != null) { if (GUILayout.Button("Preview", GUILayout.Height(24.0f))) { BehaviourTreeEditor.OpenDebug(btAsset, btInstance); } } else { if (GUILayout.Button("Edit", GUILayout.Height(24.0f))) { BehaviourTreeEditor.Open(btAsset); } } } if (m_inspector != null) { BTEditorStyle.EnsureStyle(); m_inspector.DrawGUI(); Repaint(); } else { EditorGUILayout.HelpBox("There are no values to display!", MessageType.Error); } GUI.enabled = true; }
public override void OnInspectorGUI() { serializedObject.Update(); GUI.enabled = !EditorApplication.isPlaying; EditorGUILayout.PropertyField(m_behaviourTree); EditorGUILayout.PropertyField(m_body); EditorGUILayout.PropertyField(m_updateMode); if (m_updateMode.enumValueIndex == (int)UpdateMode.AtInterval) { EditorGUILayout.PropertyField(m_updateInterval); } GUI.enabled = true; GUI.color = m_debugMode.boolValue ? Color.green : Color.red; m_debugMode.boolValue = GUILayout.Toggle(m_debugMode.boolValue, "Debug", "Button", GUILayout.Height(24.0f)); GUI.color = Color.white; serializedObject.ApplyModifiedProperties(); AIAgent agent = (AIAgent)target; BTAsset btAsset = m_behaviourTree.objectReferenceValue as BTAsset; BehaviourTree btInstance = agent.GetBehaviourTree(); GUI.enabled = btAsset != null; if (EditorApplication.isPlaying && btInstance != null) { if (GUILayout.Button("Preview", GUILayout.Height(24.0f))) { BehaviourTreeEditor.OpenDebug(btAsset, btInstance); } } else { if (GUILayout.Button("Edit", GUILayout.Height(24.0f))) { BehaviourTreeEditor.Open(btAsset); } } GUI.enabled = true; }