protected static void ShowBlockInspector(Flowchart flowchart) { if (blockInspector == null) { // Create a Scriptable Object with a custom editor which we can use to inspect the selected block. // Editors for Scriptable Objects display using the full height of the inspector window. blockInspector = ScriptableObject.CreateInstance <BlockInspector>() as BlockInspector; blockInspector.hideFlags = HideFlags.DontSave; } Selection.activeObject = blockInspector; EditorUtility.SetDirty(blockInspector); }
public override void OnInspectorGUI() { BlockInspector blockInspector = target as BlockInspector; if (blockInspector.block == null) { return; } var block = blockInspector.block; if (block == null) { return; } var flowchart = (Flowchart)block.GetFlowchart(); if (flowchart.SelectedBlocks.Count > 1) { GUILayout.Label("Multiple blocks selected"); return; }
public override void OnInspectorGUI() { BlockInspector blockInspector = target as BlockInspector; if (blockInspector.block == null) { return; } var block = blockInspector.block; if (block == null) { return; } var flowchart = (Flowchart)block.GetFlowchart(); if (flowchart.SelectedBlocks.Count > 1) { GUILayout.Label("Multiple blocks selected"); return; } //if there is no selection but we are drawing, fix that if (flowchart.SelectedBlocks.Count == 0) { flowchart.AddSelectedBlock(block); } if (activeBlockEditor == null || !block.Equals(activeBlockEditor.target)) { DestroyImmediate(activeBlockEditor); activeBlockEditor = Editor.CreateEditor(block, typeof(BlockEditor)) as BlockEditor; } UpdateWindowHeight(); float width = EditorGUIUtility.currentViewWidth; blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight)); activeBlockEditor.DrawBlockName(flowchart); activeBlockEditor.DrawBlockGUI(flowchart); GUILayout.EndScrollView(); Command inspectCommand = null; if (flowchart.SelectedCommands.Count == 1) { inspectCommand = flowchart.SelectedCommands[0]; } if (Application.isPlaying && inspectCommand != null && !inspectCommand.ParentBlock.Equals(block)) { Repaint(); return; } // Only change the activeCommand at the start of the GUI call sequence if (Event.current.type == EventType.Layout) { activeCommand = inspectCommand; } DrawCommandUI(flowchart, inspectCommand); }
public override void OnInspectorGUI() { BlockInspector blockInspector = target as BlockInspector; if (blockInspector.block == null) { return; } var block = blockInspector.block; if (block == null) { return; } var flowchart = (Flowchart)block.GetFlowchart(); if (activeBlockEditor == null || !block.Equals(activeBlockEditor.target)) { DestroyImmediate(activeBlockEditor); activeBlockEditor = Editor.CreateEditor(block) as BlockEditor; } activeBlockEditor.DrawBlockName(flowchart); UpdateWindowHeight(); float width = EditorGUIUtility.currentViewWidth; float height = windowHeight; // Using a custom rect area to get the correct 5px indent for the scroll views Rect blockRect = new Rect(5, topPanelHeight, width - 5, height + 10); GUILayout.BeginArea(blockRect); blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight)); activeBlockEditor.DrawBlockGUI(flowchart); GUILayout.EndScrollView(); Command inspectCommand = null; if (flowchart.SelectedCommands.Count == 1) { inspectCommand = flowchart.SelectedCommands[0]; } if (Application.isPlaying && inspectCommand != null && !inspectCommand.ParentBlock.Equals(block)) { GUILayout.EndArea(); Repaint(); return; } // Only change the activeCommand at the start of the GUI call sequence if (Event.current.type == EventType.Layout) { activeCommand = inspectCommand; } DrawCommandUI(flowchart, inspectCommand); }
protected static void ShowBlockInspector(Flowchart flowchart) { if (blockInspector == null) { // Create a Scriptable Object with a custom editor which we can use to inspect the selected block. // Editors for Scriptable Objects display using the full height of the inspector window. blockInspector = ScriptableObject.CreateInstance<BlockInspector>() as BlockInspector; blockInspector.hideFlags = HideFlags.DontSave; } Selection.activeObject = blockInspector; EditorUtility.SetDirty(blockInspector); }
public override void OnInspectorGUI() { BlockInspector blockInspector = target as BlockInspector; if (blockInspector.block == null) { return; } // 获取到,要显示的Block var block = blockInspector.block; if (block == null) { return; } // 获取到Block的Flowchart var flowchart = (Flowchart)block.GetFlowchart(); // 检查, // 是否只选中了一个Block if (flowchart.SelectedBlocks.Count > 1) { GUILayout.Label("Multiple blocks selected"); return; } // 创建BlockEditor!!!! // * 这里的是,BlockEditorInspector if (activeBlockEditor == null || !block.Equals(activeBlockEditor.target)) { DestroyImmediate(activeBlockEditor); activeBlockEditor = Editor.CreateEditor(block) as BlockEditor; } UpdateWindowHeight(); float width = EditorGUIUtility.currentViewWidth; // 画Inspector的上部 blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight)); { // Block Name: // * 显示Block名称 activeBlockEditor.DrawBlockName(flowchart); // 显示Inspector上方的 // Block的界面 activeBlockEditor.DrawBlockGUI(flowchart); GUILayout.EndScrollView(); } Command inspectCommand = null; // 只能编辑一个命令 if (flowchart.SelectedCommands.Count == 1) { inspectCommand = flowchart.SelectedCommands[0]; } if (Application.isPlaying && inspectCommand != null && !inspectCommand.ParentBlock.Equals(block)) { Repaint(); return; } // Only change the activeCommand at the start of the GUI call sequence if (Event.current.type == EventType.Layout) { activeCommand = inspectCommand; } DrawCommandUI(flowchart, inspectCommand); }