示例#1
0
        public static void Show(DashGraph p_graph)
        {
            RuntimeGenericMenu menu = new RuntimeGenericMenu();

            menu.AddItem(new GUIContent("Settings/Show Experimental"), DashEditorCore.EditorConfig.showExperimental, () => DashEditorCore.EditorConfig.showExperimental = !DashEditorCore.EditorConfig.showExperimental);
            menu.AddItem(new GUIContent("Settings/Show Obsolete"), DashEditorCore.EditorConfig.showObsolete, () => DashEditorCore.EditorConfig.showObsolete             = !DashEditorCore.EditorConfig.showObsolete);
            menu.AddItem(new GUIContent("Settings/Show Node Ids"), DashEditorCore.EditorConfig.showNodeIds, () => DashEditorCore.EditorConfig.showNodeIds          = !DashEditorCore.EditorConfig.showNodeIds);
            menu.AddItem(new GUIContent("Settings/Show Node Search"), DashEditorCore.EditorConfig.showNodeSearch, () => DashEditorCore.EditorConfig.showNodeSearch = !DashEditorCore.EditorConfig.showNodeSearch);
            menu.AddItem(new GUIContent("Settings/Show Node Asynchronity"), DashEditorCore.EditorConfig.showNodeAsynchronity, () => DashEditorCore.EditorConfig.showNodeAsynchronity = !DashEditorCore.EditorConfig.showNodeAsynchronity);
            menu.AddItem(new GUIContent("Settings/Enable Sound in Editor"), DashEditorCore.EditorConfig.enableSoundInPreview, () => DashEditorCore.EditorConfig.enableSoundInPreview = !DashEditorCore.EditorConfig.enableSoundInPreview);
            menu.AddItem(new GUIContent("Settings/Enable AnimateNode Interface"), DashEditorCore.EditorConfig.enableAnimateNodeInterface, () => DashEditorCore.EditorConfig.enableAnimateNodeInterface = !DashEditorCore.EditorConfig.enableAnimateNodeInterface);

            menu.AddSeparator("");
            //menu.AddItem(new GUIContent("Advanced/Validate Serialization"), false, p_graph.ValidateSerialization);
            menu.AddItem(new GUIContent("Advanced/Cleanup Null"), false, p_graph.RemoveNullReferences);
            //menu.AddItem(new GUIContent("Advanced/Cleanup Exposed"), false, p_graph.CleanupExposedReferenceTable);

            menu.AddItem(new GUIContent("Reset Graph Position"), false, p_graph.ResetPosition);

            menu.AddItem(new GUIContent("Help"), false, () =>
            {
                Application.OpenURL("https://github.com/pshtif/Dash/tree/main/Documentation");
            });

            //menu.ShowAsEditorMenu();
            GenericMenuPopup.Show(menu, "Preferences", Event.current.mousePosition, 240, 300, false, false);
        }
示例#2
0
        public static void Show(DashGraph p_graph)
        {
            RuntimeGenericMenu menu = new RuntimeGenericMenu();

            menu.AddItem(new GUIContent("Import JSON"), false, () => GraphUtils.ImportJSON(p_graph));
            menu.AddItem(new GUIContent("Export JSON"), false, () => GraphUtils.ExportJSON(p_graph));

            //menu.ShowAsContext();
            GenericMenuPopup.Show(menu, "File", Event.current.mousePosition, 240, 300, false, false);
        }
示例#3
0
        void BindGraph(DashGraph p_graph)
        {
            bool editing = DashEditorCore.EditorConfig.editingGraph == p_graph;

            Controller.BindGraph(p_graph);

            // If we are currently editing this controller refresh
            if (editing)
            {
                DashEditorCore.EditController(Controller);
            }
        }
示例#4
0
        public void Draw(DashGraph p_graph)
        {
            if (p_graph != null)
            {
                if (GUI.Button(new Rect(0, 1, 100, 22), "File"))
                {
                    GraphFileContextMenu.Show(p_graph);
                }

                GUI.DrawTexture(new Rect(80, 6, 10, 10), IconManager.GetIcon("arrowdown_icon"));

                if (GUI.Button(new Rect(102, 1, 120, 22), "Preferences"))
                {
                    PreferencesContextMenu.Show(p_graph);
                }

                GUI.DrawTexture(new Rect(202, 6, 10, 10), IconManager.GetIcon("arrowdown_icon"));

                if (DashEditorCore.EditorConfig.showNodeSearch)
                {
                    _search = GUI.TextField(new Rect(230, 2, 100, 19), _search);
                    if (GUI.Button(new Rect(332, 3, 60, 18), "Search"))
                    {
                        if (!_search.IsNullOrWhitespace())
                        {
                            if (_search != _previousSearch)
                            {
                                _previousSearch = _search;
                                _index          = 0;
                            }
                            else
                            {
                                _index++;
                            }

                            SelectionManager.SearchAndSelectNode(p_graph, _search, _index);
                        }
                    }
                }
            }
        }
示例#5
0
        public override void OnInspectorGUI()
        {
            if (DashEditorCore.EditorConfig.settingsShowInspectorLogo)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Box(Resources.Load <Texture>("Textures/dash"), GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();
            }

            if (EditorUtility.IsPersistent(target))
            {
                GUI.enabled = false;
            }

            EditorGUI.BeginChangeCheck();

            if (((IEditorControllerAccess)Controller).graphAsset == null && !Controller.HasBoundGraph)
            {
                GUILayout.BeginVertical();

                var oldColor = GUI.color;
                GUI.color = new Color(1, 0.75f, 0.5f);
                if (GUILayout.Button("Create Graph", GUILayout.Height(40)))
                {
                    if (EditorUtility.DisplayDialog("Create Graph", "Create Bound or Asset Graph?",
                                                    "Bound", "Asset"))
                    {
                        BindGraph(GraphUtils.CreateEmptyGraph());
                    }
                    else
                    {
                        ((IEditorControllerAccess)Controller).graphAsset = GraphUtils.CreateGraphAsAssetFile();
                    }
                }

                GUI.color = oldColor;

                ((IEditorControllerAccess)Controller).graphAsset =
                    (DashGraph)EditorGUILayout.ObjectField(((IEditorControllerAccess)Controller).graphAsset,
                                                           typeof(DashGraph), true);
            }
            else
            {
                GUILayout.BeginVertical();

                var oldColor = GUI.color;
                GUI.color = new Color(1, 0.75f, 0.5f);
                if (GUILayout.Button("Open Editor", GUILayout.Height(40)))
                {
                    OpenEditor();
                }

                GUI.color = oldColor;

                if (!Controller.HasBoundGraph)
                {
                    EditorGUI.BeginChangeCheck();

                    ((IEditorControllerAccess)Controller).graphAsset =
                        (DashGraph)EditorGUILayout.ObjectField(((IEditorControllerAccess)Controller).graphAsset,
                                                               typeof(DashGraph), true);

                    if (EditorGUI.EndChangeCheck())
                    {
                        DashEditorCore.EditController(Controller);
                    }

                    if (GUILayout.Button("Bind Graph"))
                    {
                        BindGraph(Controller.Graph);
                    }
                }
                else
                {
                    if (GUILayout.Button("Save to Asset"))
                    {
                        DashGraph graph = GraphUtils.CreateGraphAsAssetFile(Controller.Graph);
                        if (graph != null)
                        {
                            Controller.BindGraph(null);
                            ((IEditorControllerAccess)Controller).graphAsset = graph;
                        }
                    }

                    if (GUILayout.Button("Remove Graph"))
                    {
                        if (DashEditorCore.EditorConfig.editingGraph == Controller.Graph)
                        {
                            DashEditorCore.UnloadGraph();
                        }

                        Controller.BindGraph(null);
                    }
                }
            }

            Controller.useCustomTarget = EditorGUILayout.Toggle(
                new GUIContent("Use Custom Target", "Customize target which is this gameobject transform by default."),
                Controller.useCustomTarget);

            if (Controller.useCustomTarget == true)
            {
                Controller.customTarget =
                    (Transform)EditorGUILayout.ObjectField("Custom Target", Controller.customTarget, typeof(Transform),
                                                           true);
            }
            else
            {
                Controller.customTarget = null;
            }

            Controller.autoStart =
                EditorGUILayout.Toggle(
                    new GUIContent("Auto Start", "Automatically call an input on a graph when controller is started."),
                    Controller.autoStart);

            if (Controller.autoStart)
            {
                Controller.autoStartInput =
                    EditorGUILayout.TextField("Auto Start Input", Controller.autoStartInput);
            }

            Controller.autoOnEnable =
                EditorGUILayout.Toggle(
                    new GUIContent("Auto OnEnable",
                                   "Automatically call an input on a graph when controller is enabled."), Controller.autoOnEnable);

            if (Controller.autoOnEnable)
            {
                Controller.autoOnEnableInput =
                    EditorGUILayout.TextField("Auto OnEnable Input", Controller.autoOnEnableInput);
            }

            GUILayout.EndVertical();

            if (Controller.Graph != null)
            {
                if (Controller.HasBoundGraph)
                {
                    GUIVariableUtils.DrawVariablesInspector("Graph Variables", Controller.Graph.variables, Controller.gameObject);
                }
                else
                {
                    Controller.showGraphVariables =
                        EditorGUILayout.Toggle("Show Graph Variables", Controller.showGraphVariables);

                    if (Controller.showGraphVariables)
                    {
                        GUIStyle style = new GUIStyle();
                        style.fontStyle        = FontStyle.Italic;
                        style.normal.textColor = Color.yellow;
                        style.alignment        = TextAnchor.MiddleCenter;
                        EditorGUILayout.LabelField("Warning these are not bound to instance.", style);
                        GUIVariableUtils.DrawVariablesInspector("Graph Variables", Controller.Graph.variables, Controller.gameObject);
                    }
                }
            }

            Controller.advancedInspector = EditorGUILayout.Toggle(new GUIContent("Show Advanced Inspector", ""), Controller.advancedInspector);

            if (Controller.advancedInspector)
            {
                DrawExposedPropertiesInspector();
            }

            if (Controller.advancedInspector && Controller.Graph != null)
            {
                GUILayout.Space(16);
                DrawGraphStructureInspector();
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(target);
            }

            serializedObject.ApplyModifiedProperties();
        }