Exemplo n.º 1
0
        public static DashEditorWindow InitEditorWindow(DashController p_dashController)
        {
            DashEditorCore.EditController(p_dashController);

            Instance = GetWindow <DashEditorWindow>();
            Instance.titleContent = new GUIContent("Dash Editor");
            Instance.minSize      = new Vector2(800, 400);

            return(Instance);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        void DrawControllerInfo(Rect p_rect)
        {
            if (Graph == null)
            {
                return;
            }

            GUI.color = Color.white;
            GUIStyle style = new GUIStyle();

            style.normal.textColor = Color.white;
            style.fontSize         = 24;
            style.fontStyle        = FontStyle.Bold;
            GUI.color = new Color(1, 1, 1, 0.25f);
            if (Controller != null && Controller.HasBoundGraph)
            {
                GUI.Label(new Rect(p_rect.x + 16, p_rect.height - 40, 200, 40), "Bound", style);
            }
            else
            {
                GUI.Label(new Rect(p_rect.x + 16, p_rect.height - 40, 200, 40), "Asset", style);
            }

            if (Controller != null)
            {
                style.normal.textColor = Color.yellow;
                style.fontSize         = 18;
                GUI.Label(new Rect(p_rect.x + 16, p_rect.height - 58, 200, 40), Controller.name, style);
            }

            if (GraphUtils.IsSubGraph(DashEditorCore.EditorConfig.editingGraphPath))
            {
                if (GUI.Button(new Rect(p_rect.x + 16, p_rect.height - (Controller == null ? 80 : 98), 100, 32), "GO TO PARENT"))
                {
                    if (Controller != null)
                    {
                        DashEditorCore.EditController(Controller,
                                                      GraphUtils.GetParentPath(DashEditorCore.EditorConfig.editingGraphPath));
                    }
                    else
                    {
                        DashEditorCore.EditGraph(DashEditorCore.EditorConfig.editingRootGraph,
                                                 GraphUtils.GetParentPath(DashEditorCore.EditorConfig.editingGraphPath));
                    }
                }
            }
        }
Exemplo n.º 4
0
 void OnPrefabStageOpened(UnityEditor.Experimental.SceneManagement.PrefabStage p_stage)
 {
     //when exiting prefab state we are left with a floating graph instance which can creat confusion
     DashEditorCore.EditController(null);
 }
Exemplo n.º 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();
        }