public void OnSelectionChange() { selectedObject = Selection.activeTransform; if (selectedObject != null) { selectedDebugger = selectedObject.GetComponentInChildren <UBTDebugger>(); } Repaint(); }
private void DrawBehaviourTree(UBTDebugger debugger) { EditorGUILayout.BeginVertical(); { GUILayout.Label("Behaviour Tree:", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(nestedBoxStyle); DrawNodeTree(debugger.behaviorTree, 0); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }
private void DrawStats(UBTDebugger debugger) { EditorGUILayout.BeginVertical(); { GUILayout.Label("Stats:", EditorStyles.boldLabel); Root behaviorTree = debugger.behaviorTree; EditorGUILayout.BeginVertical(EditorStyles.helpBox); { DrawKeyValue("Active Timers: ", behaviorTree.Clock.NumTimers.ToString()); DrawKeyValue("Timer Pool Size: ", behaviorTree.Clock.DebugPoolSize.ToString()); DrawKeyValue("Active Update Observers: ", behaviorTree.Clock.NumUpdateObservers.ToString()); DrawKeyValue("Active Blackboard Observers: ", behaviorTree.Blackboard.NumObservers.ToString()); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }
public void OnGUI() { Init(); GUI.color = defaultColor; GUILayout.Toggle(false, "BT Debugger", GUI.skin.FindStyle("LODLevelNotifyText")); GUI.color = Color.white; if (!Application.isPlaying) { EditorGUILayout.HelpBox("Cannot use this utility in Editor Mode", MessageType.Info); return; } var newDebugger = (UBTDebugger)EditorGUILayout.ObjectField("Selected Debugger:", selectedDebugger, typeof(UBTDebugger), true); if (newDebugger != selectedDebugger) { selectedDebugger = newDebugger; if (newDebugger != null) { selectedObject = selectedDebugger.transform; } } if (selectedObject == null) { EditorGUILayout.HelpBox("Please select an object", MessageType.Info); return; } if (selectedDebugger == null) { EditorGUILayout.HelpBox("This object does not contain a debugger component", MessageType.Info); return; } else if (selectedDebugger.behaviorTree == null) { EditorGUILayout.HelpBox("BehavorTree is null", MessageType.Info); return; } scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUILayout.BeginHorizontal(); DrawBlackboardKeyAndValues("Blackboard:", selectedDebugger.behaviorTree.Blackboard); if (selectedDebugger.CustomStatus.Keys.Count > 0) { DrawBlackboardKeyAndValues("Custom Stats:", selectedDebugger.CustomStatus); } DrawStats(selectedDebugger); GUILayout.EndHorizontal(); GUILayout.Space(10); if (Time.timeScale <= 2.0f) { GUILayout.BeginHorizontal(); GUILayout.Label("TimeScale: "); Time.timeScale = EditorGUILayout.Slider(Time.timeScale, 0.0f, 2.0f); GUILayout.EndHorizontal(); } GUILayout.Label("Repeat Root : " + selectedDebugger.behaviorTree.RepeatRoot.ToString(), smallTextStyle); DrawBehaviourTree(selectedDebugger); GUILayout.Space(10); EditorGUILayout.EndScrollView(); Repaint(); }