Exemplo n.º 1
0
        public static bool GraphAssetOpenEditor(int instance_ID, int line)
        {
            GraphAsset asset = EditorUtility.InstanceIDToObject(instance_ID) as GraphAsset;

            if (asset)
            {
                GraphEditorWindow.OpenEditor(asset);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        private static void HierarchyIndex(int instance_id, Rect index_rect)
        {
            Event current = Event.current;

            if (styles == null)
            {
                styles = new Styles();
            }

            target = EditorUtility.InstanceIDToObject(instance_id) as GameObject;
            if (index_rect.Contains(current.mousePosition))
            {
                InputGUI();
            }
            if (target)
            {
                if (target.GetComponent <GraphController>())
                {
                    int graph_count = target.GetComponents <GraphController>().Length;

                    Rect       rect    = new Rect(index_rect.width - 10.0f, index_rect.y - 2.0f, 20.0f, 20.0f);
                    GUIContent content = new GUIContent(graph_count > 1 ? graph_count.ToString() : string.Empty, string.Empty);

                    if (GUI.Button(rect, content, styles.icon))
                    {
                        Selection.activeObject = target;
                        GraphEditorWindow.OpenEditor(target.GetComponent <GraphController>().graph);
                    }
                }
                if (set_dirty)
                {
                    UndoManager.SetDirty(target);
                    set_dirty = false;
                }
            }
            target = null;
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            bool restore_wide_mode = EditorGUIUtility.wideMode;

            EditorGUIUtility.wideMode   = true;
            EditorGUIUtility.labelWidth = 0.0f;
            EditorGUIUtility.fieldWidth = 0.0f;

            if (GUILayout.Button("Open in Editor"))
            {
                GraphEditorWindow.OpenEditor(asset);
            }
            try {
                DrawMenuMode();

                GUILayout.Space(5.0f);

                switch (currentMenu)
                {
                //Graph
                case 0:
                    string title = EditorGUILayout.TextField(asset.title);
                    GUIDraw.GhostLabel(title, "Title...", -2.0f, 5.0f);
                    if (title != asset.title)
                    {
                        UndoManager.RecordObject(target, "Title Change");
                        asset.title = title;
                        GraphEditor.current_validate = true;
                    }
                    GUILayout.Space(3.0f);
                    string subtitle = EditorGUILayout.TextArea(asset.subtitle, GUILayout.MinHeight(50.0f));
                    GUIDraw.GhostLabel(subtitle, "Subtitle...", -2.0f, 5.0f);
                    if (subtitle != asset.subtitle)
                    {
                        UndoManager.RecordObject(target, "Subtitle Change");
                        asset.subtitle = subtitle;
                        GraphEditor.current_validate = true;
                    }
                    GUILayout.Label(string.Format("Nodes: {0}", asset.graph.nodes.Count.ToString()));
                    break;

                //Parameters
                case 1:
                    input_list.DoLayoutList();
                    output_list.DoLayoutList();
                    break;

                //Variables
                case 2:
                    variable_list.DoLayoutList();
                    break;

                //Node Inspector
                case 3:
                    DrawNodeInspector();
                    break;
                }
            }
            catch {
                CreateReorderableLists();
                GraphEditor.current_validate = true;
            }

            if (GUI.changed)
            {
                UndoManager.SetDirty(target);
                GUI.changed = false;
            }

            EditorGUIUtility.wideMode = restore_wide_mode;
        }