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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }