/// <summary> /// Method responsible for the inspector visualization /// </summary> public override void OnInspectorGUI() { //Get the cosimulation debugger instance CoSimulationDebugger debugger = this.target as CoSimulationDebugger; if (debugger.SourceAvatar == null) { GUILayout.Label("Source avatar must be set in order to use the CoSimulationDebugger."); //Call the base inspector base.OnInspectorGUI(); return; } //Check if the present frame is not null if (debugger.currentFrame != null) { GUILayout.Label("Hierachy:"); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); //Draw the initial this.DrawInitial(debugger.currentHierachyIndex == 0); int index = 0; for (int i = 0; i < debugger.currentFrame.Results.Count; i++) { MSimulationResult result = debugger.currentFrame.Results[i]; MInstruction instruction = debugger.GetInstructionByID(debugger.currentFrame.Instructions[i]); DrawHierachyEntry(debugger, result, instruction, index + 1); index++; } GUI.color = Color.blue; for (int i = 0; i < debugger.currentFrame.CoSimulationSolverResults.Count; i++) { MSimulationResult result = debugger.currentFrame.CoSimulationSolverResults[i]; DrawSolverEntry(debugger, result, index + 1); index++; } GUI.color = Color.cyan; //Draw the merged resuls this.DrawMergedResult(debugger, debugger.currentFrame.MergedResult, debugger.currentHierachyIndex == -1); GUI.color = GUI.color = Color.white; } //Call the base inspector base.OnInspectorGUI(); }
/// <summary> /// Draws a respective hierachy level (corresponds to a MMU) /// </summary> /// <param name="debugger"></param> /// <param name="result"></param> /// <param name="instruction"></param> /// <param name="index"></param> private void DrawHierachyEntry(CoSimulationDebugger debugger, MSimulationResult result, MInstruction instruction, int index) { Rect rect = EditorGUILayout.BeginVertical(); GUILayout.Label("Level: " + index); bool active = index == debugger.currentHierachyIndex; if (instruction != null) { GUILayout.Label("Name: " + instruction.Name); GUILayout.Label("MotionType: " + instruction.MotionType); GUILayout.Label("Events: " + (result.Events != null?result.Events.Count:0)); if (result.Events != null) { foreach (MSimulationEvent simEvent in result.Events) { GUILayout.Label("Name: " + simEvent.Name); GUILayout.Label("Type: " + simEvent.Type); } } GUILayout.Label("Scene manipulations: " + (result.SceneManipulations != null ? result.SceneManipulations.Count : 0)); if (result.SceneManipulations != null) { if (active) { this.ShowSceneManipulations(result.SceneManipulations); } } GUILayout.Label("Number of constraints: " + (result.Constraints != null ? result.Constraints.Count : 0)); if (result.Constraints != null && result.Constraints.Count > 0) { if (debugger.AutoDisplayConstraints) { if (active) { this.ShowConstraints(result.Constraints); } } else { if (GUILayout.Button("Show constraints")) { this.ShowConstraints(result.Constraints); } } } //Show the log data if (result.LogData != null) { foreach (string log in result.LogData) { GUILayout.Label(log); } } } GUILayout.EndVertical(); if (active) { EditorGUI.DrawRect(rect, new Color(0, 1.0f, 0, 0.2f)); } else { EditorGUI.DrawRect(rect, new Color(1.0f, 1.0f, 1.0f, 0.2f)); } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); }