예제 #1
0
        static void GetAvailableColors()
        {
            settings        = (FREditorSettings)FREditorSettings.GetSerializedSettings().targetObject as FREditorSettings;
            availableColors = new Dictionary <string, Color>();

            if (EditorGUIUtility.isProSkin)
            {
                for (int d = 0; d < settings.defaultColorsDark.Count; d++)
                {
                    availableColors.Add(settings.defaultColorsDark[d].id, settings.defaultColorsDark[d].color);
                }
            }
            else
            {
                for (int d = 0; d < settings.defaultColorsLight.Count; d++)
                {
                    availableColors.Add(settings.defaultColorsLight[d].id, settings.defaultColorsLight[d].color);
                }
            }

            for (int c = 0; c < settings.categoryColors.Count; c++)
            {
                availableColors.Add(settings.categoryColors[c].id, settings.categoryColors[c].color);
            }

            whiteBox = EditorHelpers.LoadGraphic("whiteBox.png");
        }
        static void UpdateSettings()
        {
            // Get current settings
            var _tmpSettings = (FREditorSettings)FREditorSettings.GetSerializedSettings().targetObject as FREditorSettings;

            if (_tmpSettings.version != EditorHelpers.GetEditorVersion())
            {
                // get new settings
                var _newSettings = ScriptableObject.CreateInstance <FREditorSettings>();

                _newSettings.ResetColors();
                _newSettings.ResetShortcuts();

                // Compare default colors
                if (_tmpSettings.defaultColorsDark.Count != _newSettings.defaultColorsDark.Count)
                {
                    for (int d = 0; d < _newSettings.defaultColorsDark.Count; d++)
                    {
                        var _exists = false;
                        for (int e = 0; e < _tmpSettings.defaultColorsDark.Count; e++)
                        {
                            if (_tmpSettings.defaultColorsDark[e].id == _newSettings.defaultColorsDark[d].id)
                            {
                                _exists = true;
                            }
                        }

                        if (!_exists)
                        {
                            _tmpSettings.defaultColorsDark.Add(_newSettings.defaultColorsDark[d]);
                            _tmpSettings.defaultColorsLight.Add(_newSettings.defaultColorsLight[d]);
                        }
                    }
                }


                if (_tmpSettings.inspectorColors == null || _tmpSettings.inspectorColors.Count == 0)
                {
                    _tmpSettings.inspectorColors = new List <EditorColors>()
                    {
                        new EditorColors("inspectorColor", new Color(165f / 255f, 140f / 255f, 205f / 255, 255f / 255f)),
                        new EditorColors("blackboardColor", Color.black),
                        new EditorColors("eventboardColor", new Color(120f / 255f, 195f / 255f, 255f / 255, 255f / 255f)),
                    };
                }

                _tmpSettings.version = EditorHelpers.GetEditorVersion();
            }
        }
        public static SettingsProvider CreateMyCustomSettingsProvider()
        {
            // First parameter is the path in the Settings window.
            // Second parameter is the scope of this setting: it only appears in the Project Settings window.
            var provider = new SettingsProvider("FREditorSettings", SettingsScope.User)
            {
                // By default the last token of the path is used as display name if no label is provided.
                label = "FlowReactor",
                // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
                guiHandler = (searchContext) =>
                {
                    var settings = (FREditorSettings)FREditorSettings.GetSerializedSettings().targetObject as FREditorSettings;



                    FREditorSettingsGUI.Draw(settings);
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                keywords = new HashSet <string>(new[] { "FlowReactor" })
            };

            return(provider);
        }
예제 #4
0
        public static Node CreateNode(NodeCategoryTree.NodeData _nodeData, Graph _rootGraph, Graph _graphOwner, string _type, Vector2 _position, bool _isCopy)
        {
            if (_nodeData == null)
            {
                allNodes  = CollectAvailableNodes.CollectNodes();
                _nodeData = allNodes.GetData(_type);
            }

            Node node = Node.CreateNode(_type, _nodeData.typeName);

            // Assign attributes to node
            node.outputNodes = new List <Node.NodeOutput>();            //(_nodeAttributes.outputSlotCount);
            if (_nodeData.outputSlotCount > -1)
            {
                for (int i = 0; i < _nodeData.outputSlotCount; i++)
                {
                    node.outputNodes.Add(new Node.NodeOutput());
                }
            }
            if (_nodeData.nodeOutputs != null)
            {
                for (int i = 0; i < _nodeData.nodeOutputs.Length; i++)
                {
                    node.outputNodes.Add(new Node.NodeOutput(_nodeData.nodeOutputs[i]));
                }
            }


            //_position = new Vector2(_position.x / _rootGraph.zoomFactor, _position.y / _rootGraph.zoomFactor);

            node.inputNodes = new List <Node.InputNode>();
            node.nodeRect   = new Rect(_position.x, _position.y, node.nodeRect.width, node.nodeRect.height);

            // Get settings
            var _editorSettings = (FREditorSettings)FREditorSettings.GetSerializedSettings().targetObject as FREditorSettings;

            node.color    = _editorSettings.GetColor(_nodeData.color);
            node.nodeData = _nodeData;
            node.isCopy   = _isCopy;
            node.guid     = Guid.NewGuid().ToString();

            _graphOwner.AddNode(node);

            node.rootGraph  = _rootGraph;
            node.graphOwner = _graphOwner;
            //node.nodeStringType = _type;
            if (!_isCopy)
            {
                node.Init(_rootGraph, node);                 // _graphOwner.nodes.Count, node);
            }

            if (node.outputNodes.Count > 1)
            {
                node.nodeRect.height += (node.outputNodes.Count - 1) * 20;
            }

            node.SetupVariables();

            // check if newly created node has been created inside a group
            // if true, add new node to this group
            for (int n = 0; n < _rootGraph.currentGraph.nodes.Count; n++)
            {
                if (_rootGraph.currentGraph.nodes[n].nodeData.nodeType == NodeAttributes.NodeType.Group &&
                    _rootGraph.currentGraph.nodes[n] != node && _rootGraph.currentGraph.nodes[n].nodeRect.Contains(new Vector2(node.nodeRect.x, node.nodeRect.y)))
                {
                    var _g = _rootGraph.currentGraph.nodes[n] as Group;
                    _g.AddNodeToGroup(node);
                }
            }

            EditorUtility.SetDirty(node);
            EditorUtility.SetDirty(_rootGraph);

            node.lastZoomCoordsOrigin = _rootGraph.currentGraph.zoomCoordsOrigin;

            // Better than AssetDatabase SaveAsset or Refresh for refreshing node
            Undo.SetCurrentGroupName("Create Node");
            int undoGroup = Undo.GetCurrentGroup();

            Undo.RecordObject(node, "Create Node");
            Undo.CollapseUndoOperations(undoGroup);


            return(node);
        }