Exemple #1
0
        public void DrawCommandUI(Flowchart flowchart, Command inspectCommand)
        {
            ResizeScrollView(flowchart);

            GUILayout.Space(7);

            activeBlockEditor.DrawButtonToolbar();

            commandScrollPos = GUILayout.BeginScrollView(commandScrollPos);

            if (inspectCommand != null)
            {
                if (activeCommandEditor == null ||
                    inspectCommand != activeCommandEditor.target)
                {
                    // See if we have a cached version of the command editor already,
                    var editors = (from e in cachedCommandEditors where (e != null && e.target == inspectCommand) select e);

                    if (editors.Count() > 0)
                    {
                        // Use cached editor
                        activeCommandEditor = editors.First();
                    }
                    else
                    {
                        // No cached editor, so create a new one.
                        activeCommandEditor = Editor.CreateEditor(inspectCommand) as CommandEditor;
                        cachedCommandEditors.Add(activeCommandEditor);
                    }
                }
                if (activeCommandEditor != null)
                {
                    activeCommandEditor.DrawCommandInspectorGUI();
                }
            }

            GUILayout.EndScrollView();

            GUILayout.EndArea();

            // Draw the resize bar after everything else has finished drawing
            // This is mainly to avoid incorrect indenting.
            Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f);

            GUI.color = new Color(0.64f, 0.64f, 0.64f);
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            resizeRect.height = 1;
            GUI.color         = new Color32(132, 132, 132, 255);
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            resizeRect.y += 3;
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            Repaint();
        }
        public override void OnInspectorGUI()
        {
            SequenceInspector sequenceInspector = target as SequenceInspector;
            Sequence          sequence          = sequenceInspector.sequence;

            if (sequence == null)
            {
                return;
            }

            FungusScript fungusScript = sequence.GetFungusScript();

            SequenceEditor sequenceEditor = Editor.CreateEditor(sequence) as SequenceEditor;

            sequenceEditor.DrawSequenceGUI(fungusScript);
            DestroyImmediate(sequenceEditor);

            Command inspectCommand = null;

            if (fungusScript.selectedCommands.Count == 1)
            {
                inspectCommand = fungusScript.selectedCommands[0];
            }

            if (Application.isPlaying &&
                inspectCommand != null &&
                inspectCommand.parentSequence != sequence)
            {
                Repaint();
                return;
            }

            if (inspectCommand != null)
            {
                CommandEditor commandEditor = Editor.CreateEditor(inspectCommand) as CommandEditor;
                commandEditor.DrawCommandInspectorGUI();
                DestroyImmediate(commandEditor);
            }

            Repaint();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            FungusScript t = target as FungusScript;

            t.UpdateHideFlags();

            if (Application.isPlaying)
            {
                if (t.executingSequence == null)
                {
                    t.selectedCommand = null;
                }
                else
                {
                    t.selectedCommand = t.executingSequence.activeCommand;
                }
            }

            EditorGUILayout.PropertyField(stepTimeProp, new GUIContent("Step Time", "Minimum time to execute each step"));

            SequenceEditor.SequenceField(startSequenceProp,
                                         new GUIContent("Start Sequence", "Sequence to be executed when controller starts."),
                                         new GUIContent("<None>"),
                                         t);

            if (t.startSequence == null)
            {
                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.normal.textColor = new Color(1, 0, 0);
                EditorGUILayout.LabelField(new GUIContent("Error: Please select a Start Sequence"), style);
            }

            EditorGUILayout.PropertyField(executeOnStartProp, new GUIContent("Execute On Start", "Execute this Fungus Script when the scene starts."));

            EditorGUILayout.PropertyField(colorCommandsProp, new GUIContent("Color Commands", "Display commands using colors in editor window."));

            EditorGUILayout.PropertyField(showSequenceObjectsProp, new GUIContent("Show Sequence Objects", "Display the child Sequence game objects in the hierarchy view."));

            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Open Editor"))
            {
                EditorWindow.GetWindow(typeof(FungusScriptWindow), false, "Fungus Script");
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            if (t.selectedCommand != null)
            {
                CommandEditor commandEditor = Editor.CreateEditor(t.selectedCommand) as CommandEditor;
                commandEditor.DrawCommandInspectorGUI();
                DestroyImmediate(commandEditor);
            }

            EditorGUILayout.Separator();

            DrawVariablesGUI();

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            BlockInspector blockInspector = target as BlockInspector;
            Block          block          = blockInspector.block;

            if (block == null)
            {
                return;
            }

            Flowchart flowchart = block.GetFlowchart();

            BlockEditor blockEditor = Editor.CreateEditor(block) as BlockEditor;

            blockEditor.DrawBlockName(flowchart);

            // Using a custom rect area to get the correct 5px indent for the scroll views
            Rect blockRect = new Rect(5, topPanelHeight, Screen.width - 6, Screen.height - 70);

            GUILayout.BeginArea(blockRect);

            blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.blockViewHeight));
            blockEditor.DrawBlockGUI(flowchart);
            GUILayout.EndScrollView();

            Command inspectCommand = null;

            if (flowchart.selectedCommands.Count == 1)
            {
                inspectCommand = flowchart.selectedCommands[0];
            }

            if (Application.isPlaying &&
                inspectCommand != null &&
                inspectCommand.parentBlock != block)
            {
                GUILayout.EndArea();
                Repaint();
                DestroyImmediate(blockEditor);
                return;
            }

            ResizeScrollView(flowchart);

            GUILayout.Space(7);

            blockEditor.DrawButtonToolbar();

            commandScrollPos = GUILayout.BeginScrollView(commandScrollPos);

            if (inspectCommand != null)
            {
                CommandEditor commandEditor = Editor.CreateEditor(inspectCommand) as CommandEditor;
                commandEditor.DrawCommandInspectorGUI();
                DestroyImmediate(commandEditor);
            }

            GUILayout.EndScrollView();

            GUILayout.EndArea();

            // Draw the resize bar after everything else has finished drawing
            // This is mainly to avoid incorrect indenting.
            Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f);

            GUI.color = new Color(0.64f, 0.64f, 0.64f);
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            resizeRect.height = 1;
            GUI.color         = new Color32(132, 132, 132, 255);
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            resizeRect.y += 3;
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            Repaint();

            DestroyImmediate(blockEditor);
        }