예제 #1
0
        void DrawSceneWindow(int id)
        {
            debugMode = GUILayout.Toggle(debugMode, "Debug mode", GUILayout.Width(100f));

            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical("box");
                {
                    int selectedState = (int)currentEditorState;
                    selectedState = GUILayout.SelectionGrid(selectedState, System.Enum.GetNames(typeof(GraphEditorState)), 1, GUILayout.Width(100f));
                    currentEditorState = (GraphEditorState)selectedState;
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical();

                switch (currentEditorState)
                {
                    case GraphEditorState.None:
                        singleSelectedPrimitiveIdx = -1;
                        break;
                    case GraphEditorState.Nodes:
                        singleSelectedPrimitiveIdx = -1;
                        DrawNodeSceneTools();
                        break;
                    case GraphEditorState.Edges:
                        singleSelectedPrimitiveIdx = -1;
                        DrawEdgeSceneTools();
                        break;
                    case GraphEditorState.Primitives:
                        DrawPrimitiveSceneTools();
                        break;
                    default:
                        singleSelectedPrimitiveIdx = -1;
                        break;
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            GUI.changed = true;
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            showData = EditorGUILayout.Foldout(showData, "Data Modification");
            if (showData)
            {
                EditorGUILayout.BeginVertical("box");

                EditorGUI.indentLevel = 1;

                serializedObject.Update();

                EditorGUI.BeginChangeCheck();
                // Draw nodes list
                SerializedProperty nodes = serializedObject.FindProperty("nodes");
                EditorGUILayout.PropertyField(nodes, true);

                // Draw edges list
                SerializedProperty edges = serializedObject.FindProperty("edges");
                EditorGUILayout.PropertyField(edges, true);

                if (EditorGUI.EndChangeCheck())
                    serializedObject.ApplyModifiedProperties();

                EditorGUI.indentLevel = 0;

                if (graph.nodes == null) graph.nodes = new List<Node>();
                if (graph.edges == null) graph.edges = new List<Edge>();

                if (GUILayout.Button("Clear nodes", GUILayout.Width(100f)))
                {
                    graph.nodes = new List<Node>();
                }

                if (GUILayout.Button("Clear edges", GUILayout.Width(100f)))
                {
                    graph.edges = new List<Edge>();
                }

                if (GUILayout.Button("Clear SubPrimitives", GUILayout.Width(130f)))
                {
                    graph.ClearPrimitiveSubPrimitives();
                }

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.Separator();

            if (GUILayout.Button("Process Minimal Cycles", GUILayout.Width(200f)))
            {
                singleSelectedPrimitiveIdx = -1;
                graph.ProcessMinimalCycles();
                graph.ProcessPrimitives();

                currentEditorState = GraphEditorState.Primitives;
            }

            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Child Edge Width", GUILayout.Width(100f));
            childEdgeWidth = EditorGUILayout.FloatField(childEdgeWidth, GUILayout.Width(70f));
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Extract Main Primitives to Children", GUILayout.Width(250f)))
            {
                graph.ExtractMainPrimitives(childEdgeWidth);
            }

            EditorGUILayout.Separator();

            if (graph.mainPrimitives != null && graph.mainPrimitives.Count > 0)
            {
                EditorGUILayout.BeginVertical("box");
                {
                    GUILayout.Label("Sub Edge Generation");

                    EditorGUILayout.BeginHorizontal("box");
                    if (GUILayout.Button("Seed", GUILayout.Width(50f)))
                    {
                        GetNewSeed();
                    }
                    graph.randomSeed = EditorGUILayout.IntField(graph.randomSeed, GUILayout.Width(200f));
                    EditorGUILayout.EndHorizontal();

                    //EditorGUILayout.BeginHorizontal();
                    //if (GUILayout.Button("Generate Sub Edges", GUILayout.Width(200f)))
                    //{
                    //    graph.ProcessPrimitives();
                    //    graph.ClearPrimitiveSubPrimitives();
                    //    graph.GeneratePrimitiveSubEdges(graph.randomSeed);
                    //}

                    //if (GUILayout.Button("With new seed", GUILayout.Width(100f)))
                    //{
                    //    graph.ProcessPrimitives();
                    //    graph.ClearPrimitiveSubPrimitives();

                    //    GetNewSeed();

                    //    graph.GeneratePrimitiveSubEdges(graph.randomSeed);
                    //}
                    //EditorGUILayout.EndHorizontal();

                    //if (GUILayout.Button("Process Sub Primitives", GUILayout.Width(200f)))
                    //{
                    //    graph.ClearPrimitiveSubPrimitives();
                    //    graph.ProcessPrimitiveSubPrimitives();
                    //}

                    EditorGUILayout.LabelField("Primitive count: " + graph.mainPrimitives.Count);
                    DrawPrimitiveInspector();
                }
                EditorGUILayout.EndVertical();
            }

            FacadeBuilder builder = graph.GetComponent<FacadeBuilder>();
            if (builder != null)
            {
                EditorGUILayout.BeginVertical("box");
                {
                    GUILayout.Label("Facades");
                    EditorGUILayout.BeginVertical("box");
                    {
                        EditorGUILayout.HelpBox("Calls facade building script on all SubGraphs if they exist.", MessageType.None);
                        if (GUILayout.Button("Build all SubGraph facades", GUILayout.Width(200f)))
                        {
                            for (int i = 0; i < graph.transform.childCount; i++)
                            {
                                FacadeBuilder childBuilder = graph.transform.GetChild(i).GetComponent<FacadeBuilder>();
                                if (childBuilder == null) continue;

                                childBuilder.BuildFacades();
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
            }

            if (GUI.changed)
                EditorUtility.SetDirty(graph);
        }