Example #1
0
 public static void ClearSelection()
 {
     foreach (Node n in selection)
     {
         n.is_selected = false;
     }
     selection = new List <Node>();
     EditorUtils.RepaintInspector();
 }
Example #2
0
 public static void DeselectNode(Node node, bool move = true)
 {
     node.is_selected = false;
     selection.Remove(node);
     if (move)
     {
         graph.nodes = graph.nodes.MoveItemToStart(node);
     }
     Selection.activeObject = asset;
     EditorUtils.RepaintInspector();
 }
Example #3
0
 public static void SelectNode(Node node, bool move = true)
 {
     node.is_selected = true;
     if (!selection.Contains(node))
     {
         selection.Add(node);
     }
     if (move)
     {
         graph.nodes = graph.nodes.MoveItemToEnd(node);
     }
     Selection.activeObject = asset;
     EditorUtils.RepaintInspector();
 }
Example #4
0
 public static void SelectOnlyNode(Node node, bool move = true)
 {
     foreach (Node n in GraphEditor.selection)
     {
         n.is_selected = false;
     }
     node.is_selected = true;
     selection        = new List <Node>()
     {
         node
     };
     if (move)
     {
         graph.nodes = graph.nodes.MoveItemToEnd(node);
     }
     Selection.activeObject = asset;
     EditorUtils.RepaintInspector();
 }
Example #5
0
        public static void DeselectNodes(List <Node> nodes, bool move = true)
        {
            List <Node> local_nodes = new List <Node>(nodes);

            foreach (Node node in local_nodes)
            {
                node.is_selected = false;
                selection.Remove(node);
            }
            if (move)
            {
                foreach (Node node in local_nodes)
                {
                    graph.nodes = graph.nodes.MoveItemToStart(node);
                }
            }
            Selection.activeObject = asset;
            EditorUtils.RepaintInspector();
        }
Example #6
0
        public static void SelectNodes(List <Node> nodes, bool move = true)
        {
            List <Node> local_nodes = new List <Node>(nodes);

            foreach (Node node in local_nodes)
            {
                node.is_selected = true;
                if (!selection.Contains(node))
                {
                    selection.Add(node);
                }
            }
            if (move)
            {
                foreach (Node node in local_nodes)
                {
                    graph.nodes = graph.nodes.MoveItemToEnd(node);
                }
            }
            Selection.activeObject = asset;
            EditorUtils.RepaintInspector();
        }
Example #7
0
        public override void OnInspectorGUI()
        {
            GraphController controller = (GraphController)target;
            GraphAsset      graph      = controller.graph;

            OnEnableAction  on_enable  = controller.on_enable;
            bool            once       = controller.once;
            float           seconds    = controller.seconds;
            OnDisableAction on_disable = controller.on_disable;

            controller.CopyParameters();

            graph = (GraphAsset)EditorGUILayout.ObjectField(new GUIContent("Graph"), controller.graph, typeof(GraphAsset), false);

            if (controller.graph != graph)
            {
                controller.OnGraphChange(controller.graph, graph);
            }

            if (controller.graph)
            {
                on_enable = (OnEnableAction)EditorGUILayout.EnumPopup(new GUIContent("OnEnable"), controller.on_enable);

                switch (on_enable)
                {
                case OnEnableAction.DoNothing:
                case OnEnableAction.PlayGraph:
                    if (height != 0.0f)
                    {
                        height = 0.0f;
                        EditorUtils.RepaintInspector();
                    }
                    seconds = 0.0f;
                    break;

                case OnEnableAction.WaitForSeconds:
                    GUILayout.BeginVertical("Box");
                    if (height != EditorGUIUtility.singleLineHeight)
                    {
                        height = Mathf.MoveTowards(height, EditorGUIUtility.singleLineHeight, 1.0f);
                        EditorUtils.RepaintInspector();
                    }
                    once    = EditorGUILayout.Toggle(new GUIContent("Only Once"), controller.once, GUILayout.Height(height));
                    seconds = EditorGUILayout.FloatField(new GUIContent("Seconds"), controller.seconds, GUILayout.Height(height));
                    GUILayout.EndVertical();
                    break;
                }
                on_disable = (OnDisableAction)EditorGUILayout.EnumPopup(new GUIContent("OnDisable"), controller.on_disable);

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Ping to Asset"))
                {
                    EditorGUIUtility.PingObject(controller.graph);
                }
                if (GUILayout.Button("Open in Editor"))
                {
                    GraphEditorWindow.OpenEditor(controller.graph);
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal("RL Header");
            {
                GUILayout.Space(15.0f);
                GUILayout.BeginVertical();
                {
                    foldout = EditorGUILayout.Foldout(foldout, new GUIContent(string.Format("Variables [{0}]", controller.properties.Values.Where(p => p.is_public).Count())));
                }
                GUILayout.EndVertical();
                if (GUILayout.Toggle(debug, debug ? "Debug" : "Normal", (GUIStyle)"minibutton") != debug)
                {
                    debug = !debug;
                }
            }
            GUILayout.EndHorizontal();

            if (foldout)
            {
                GUILayout.BeginHorizontal("RL Background", GUILayout.MinHeight(10.0f));
                {
                    GUILayout.Space(10.0f);
                    GUILayout.BeginVertical();
                    {
                        foreach (VariableObject property in controller.properties.Values.ToList())
                        {
                            if (property.is_public || debug)
                            {
                                object last_value = property.GetValue();
                                object new_value  = GUIDraw.AnyField(last_value, property.valueType, debug ? property.name + string.Format(" (ID = {0}, Type = {1})", property.id, property.valueType.GetTypeName(true, true)) : property.name);
                                if (new_value != last_value)
                                {
                                    UndoManager.RecordObject(target, "Change Value");
                                    property.SetValue(new_value);
                                }
                            }
                        }
                    }
                    GUILayout.Space(5.0f);
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }

            if (GUI.changed)
            {
                UndoManager.RecordObject(target, "GraphController Inspector");
                controller.graph      = graph;
                controller.on_enable  = on_enable;
                controller.once       = once;
                controller.seconds    = seconds;
                controller.on_disable = on_disable;
                UndoManager.SetDirty(target);
            }
        }