Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            using (new GUILayout.HorizontalScope("Box"))
            {
                GUILayout.Label(logo);
            }

            if (GUILayout.Button("Edit", GUILayout.Height(40)))
            {
                //GraphEditor window = null;

                //var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();
                //if (_settings.graphWindows.TryGetValue(graph.GetInstanceID(), out window))
                //{
                //	window.Init(window, graph);
                //	window.Focus();
                //}
                //else
                //{
                //	window = CreateInstance<GraphEditor>();
                //	_settings.graphWindows.Add(graph.GetInstanceID(), window);
                //	window.Init(window, graph);
                //}
                var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();
                _settings.OpenGraphWindow(graph);
            }

            // DEBUG
                        #if FLOWREACTOR_DEBUG
            DrawDefaultInspector();
                        #endif
        }
Esempio n. 2
0
            IEnumerator UpdateFavouritesIE()
            {
                collectedNodes.categories.Remove("Favorites");

                var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();
                List <CollectAvailableNodes.CollectedNodesData> coll = new List <CollectAvailableNodes.CollectedNodesData>();

                for (int f = 0; f < _settings.favoredNodes.Count; f++)
                {
                    coll.Insert(0, new CollectAvailableNodes.CollectedNodesData
                                (
                                    //_settings.favoredNodes[f].name,
                                    _settings.favoredNodes[f].title,
                                    _settings.favoredNodes[f].typeName,
                                    _settings.favoredNodes[f].nameSpace,
                                    "Favorites",
                                    _settings.favoredNodes[f].description,
                                    _settings.favoredNodes[f].color,
                                    _settings.favoredNodes[f].outputSlotCount,
                                    _settings.favoredNodes[f].nodeOutputs,
                                    _settings.favoredNodes[f].nodeType

                                ));
                }


                for (int c = 0; c < coll.Count; c++)
                {
                    var _child = collectedNodes.BuildTree(coll[c].category, coll[c].name);

                    _child.AddNode
                    (
                        //coll[c].name,
                        coll[c].title,
                        coll[c].typeName,
                        coll[c].nameSpace,
                        coll[c].category,
                        coll[c].description,
                        coll[c].color,
                        coll[c].outputCount,
                        coll[c].nodeOutputs,
                        coll[c].nodeType
                    );
                }

                yield return(new WaitForSeconds(0.2f));

                stopTraversing = false;
            }
        //[UnityEditor.Callbacks.DidReloadScripts]
        static void ShowChangelogAfterCompilation()
        {
            if (settings == null)
            {
                settings = FREditorSettings.GetOrCreateSettings();
            }

            var _newVersion = EditorHelpers.GetEditorVersion();

            if (settings.version != _newVersion)
            {
                settings.version = _newVersion;
                FlowReactorChangelogWindow.Init();
            }
        }
Esempio n. 4
0
        public static bool OpenGraph(int instanceID, int line)
        {
            object _obj   = EditorUtility.InstanceIDToObject(instanceID);
            var    _graph = _obj as Graph;

            if (_graph != null)
            {
                //var window = CreateInstance<GraphEditor>();
                //window.Init(window, _graph);
                var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();
                _settings.OpenGraphWindow(_graph);


                return(true);
            }
            else
            {
                return(false);
            }
        }
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            var _settings = FREditorSettings.GetOrCreateSettings();

            _settings.errorReport = "";

            //foreach (string str in importedAssets)
            //{
            //	Debug.Log("Reimported Asset: " + str);
            //}

            foreach (string str in deletedAssets)
            {
                _settings.errorReport += "deleted file: " + str + "\n";
            }

            for (int i = 0; i < movedAssets.Length; i++)
            {
                _settings.errorReport += "old file: " + movedFromAssetPaths[i] + " new file: " + movedAssets[i] + "\n";
            }
        }
        public override void OnInspectorGUI()
        {
            if (editorSkin == null)
            {
                editorSkin  = EditorHelpers.LoadSkin();
                editIcon    = EditorHelpers.LoadIcon("editIcon.png");
                refreshIcon = EditorHelpers.LoadIcon("refreshIcon.png");
                okIcon      = EditorHelpers.LoadIcon("checkmarkIcon.png");
                cancelIcon  = EditorHelpers.LoadIcon("cancelIcon.png");
            }


            if (fr != null && fr.graph != null)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }


            using (new GUILayout.HorizontalScope("Box"))
            {
                if (GUILayout.Button((Application.isPlaying && fr.runUniqueInstance) ? "Open instance" : "Open", GUILayout.Height(50)))
                {
                    //var window = CreateInstance<GraphEditor>();
                    //window.Init(window, fr.graph);
                    var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();
                    _settings.OpenGraphWindow(fr.graph);

                    // Check if graph needs to be updated
                    GraphUpdater.UpdateGraph(fr.graph);
                }

                if (Application.isPlaying && fr.runUniqueInstance)
                {
                    if (GUILayout.Button("Open original", GUILayout.Height(50)))
                    {
                        //var window = CreateInstance<GraphEditor>();
                        //window.Init(window, fr.originalGraph);
                        var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();
                        _settings.OpenGraphWindow(fr.originalGraph);
                    }
                }
            }

            GUI.enabled = true;

            EditorGUI.BeginChangeCheck();

            using (new GUILayout.HorizontalScope("Box"))
            {
                fr.graph = (Graph)EditorGUILayout.ObjectField(fr.graph, typeof(Graph), false);


                if (GUILayout.Button("New Graph"))
                {
                    NodeCreator.CreateNewGraphWithDefaultNodes(fr);
                }
            }

            using (new GUILayout.VerticalScope(("Box")))
            {
                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Graph settings");
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("?", GUILayout.Width(18)))
                    {
                        Application.OpenURL("https://flowreactor.io/documentation/flowreactor-component/");
                    }
                }

                fr.runUniqueInstance   = GUILayout.Toggle(fr.runUniqueInstance, "unique instance");
                fr.useGlobalUpdateLoop = GUILayout.Toggle(fr.useGlobalUpdateLoop, "global update loop");
            }

            if (fr.graph == null)
            {
                return;
            }


            // cache keys which needs to be removed
            List <string> cleanupKeys = new List <string>();



            EditorHelpers.DrawUILine();

            #region nodecontrollables

            // NODE CONTROLLABLES
            ////////////////////////////
            using (new GUILayout.HorizontalScope("Toolbar"))
            {
                GUILayout.Label("Node controlled objects", "boldLabel");

                GUILayout.FlexibleSpace();

                if (GUILayout.Button(new GUIContent(refreshIcon, "Collect all controllable nodes"), "toolbarButton"))
                {
                    fr.graph.RegisterINodeControllables(fr);

                    UpdateControllablesDictionary();
                }

                if (GUILayout.Button("?", "toolbarButton"))
                {
                    Application.OpenURL("https://flowreactor.io/documentation/frnodemodules/");
                }
            }

            if (fr.nodeControllables != null && fr.nodeControllables.Count > 0)
            {
                EditorGUI.BeginChangeCheck();
                using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
                {
                    if (fr.nodeControllables != null)
                    {
                        foreach (Node node in fr.nodeControllables.Keys)
                        {
                            using (new GUILayout.VerticalScope("Box"))
                            {
                                using (new GUILayout.HorizontalScope("Toolbar"))
                                {
                                    GUILayout.Label(node.nodeData.title);

                                    GUILayout.FlexibleSpace();
                                }

                                Dictionary <string, INodeControllable> tempController = new Dictionary <string, INodeControllable>();

                                foreach (var faces in fr.nodeControllables[node].interfaces.Keys)
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        GUILayout.Label(faces);
                                        var _lastRect = GUILayoutUtility.GetLastRect();

                                        var _obj = EditorGUILayout.ObjectField((UnityEngine.Object)fr.nodeControllables[node].interfaces[faces], typeof(INodeControllable), true);

                                        if (GUILayout.Button("select"))
                                        {
                                            PopupWindow.Show(_lastRect, new PopupShowINodeControllableObjects(node, faces));
                                        }
                                        //fr.gameControllerInterfaces[node].interfaces[faces]  = _obj as INodeController;
                                        tempController.Add(faces, _obj as INodeControllable);
                                    }
                                }

                                foreach (var t in tempController.Keys)
                                {
                                    fr.nodeControllables[node].interfaces[t] = tempController[t];
                                }
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("null");
                    }
                }


                if (EditorGUI.EndChangeCheck())
                {
                    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                }
            }


            EditorHelpers.DrawUILine();
            ////////////////////////////
            #endregion

            #region exposedvariables

            // EXPOSED VARIABLES
            ////////////////////////////
            using (new GUILayout.HorizontalScope("Toolbar"))
            {
                GUILayout.Label("Exposed variables", "boldLabel");

                GUILayout.FlexibleSpace();

                if (GUILayout.Button(new GUIContent(refreshIcon, "Manually collect and update exposed variables from nodes"), "ToolbarButton"))
                {
                    fr.CollectAndUpdateAllExposedVariables();
                }

                                #if FLOWREACTOR_DEBUG
                GUI.color = Color.yellow;
                if (GUILayout.Button("Clear exposed variables", "ToolbarButton"))
                {
                    fr.exposedNodeVariables       = new Dictionary <string, Dictionary <string, FRVariable> >();
                    fr.graph.exposedNodeVariables = new Dictionary <string, Graph.ExposedVariables>();
                }
                GUI.color = Color.white;
                                #endif
            }


            if (fr.exposedNodeVariables != null)
            {
                if (fr.exposedNodeVariables.Keys.Count > 0)
                {
                    var i = 0;

                    using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
                    {
                        foreach (string exposedNodeKey in fr.exposedNodeVariables.Keys)
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                GUI.color = colorsDarkSkin[i % 2];
                            }
                            else
                            {
                                GUI.color = colorsLighSkin[i % 2];
                            }
                            using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxWhite")))
                            {
                                GUI.color = Color.white;

                                GUILayout.Label(exposedNodeKey, "boldLabel");


                                List <string> _variableKeys = fr.exposedNodeVariables[exposedNodeKey].Keys.ToList();
                                for (int s = 0; s < _variableKeys.Count; s++)
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        var _variableKey     = _variableKeys[s];
                                        var _exposedVariable = fr.exposedNodeVariables[exposedNodeKey][_variableKey];
                                        var _varType         = _exposedVariable.GetType().Name.ToString();
                                        GUILayout.Label(new GUIContent(_varType, "GetExposedVariable<" + _varType + ">(" + "\"" + exposedNodeKey + "\"," + "\"" + _variableKey + "\");"), GUILayout.Width(80));

                                        GUI.enabled = _exposedVariable.editExposedName;
                                        _exposedVariable.exposedName = GUILayout.TextField(_exposedVariable.exposedName, GUILayout.Width(100));
                                        GUI.enabled = true;


                                        if (_exposedVariable.editExposedName)
                                        {
                                            if (string.IsNullOrEmpty(_exposedVariable.exposedName))
                                            {
                                                GUI.enabled = false;
                                            }


                                            if (GUILayout.Button(okIcon, GUILayout.Width(20), GUILayout.Height(20)))
                                            {
                                                _exposedVariable.editExposedName = false;


                                                var _fromName = _variableKey;
                                                var _newName  = _exposedVariable.exposedName;

                                                                                                #if FLOWREACTOR_DEBUG
                                                Debug.Log("update key from: " + _fromName + " to: " + _newName);
                                                                                                #endif

                                                // check if new name already exists
                                                bool _nameAlreadyExists = false;
                                                foreach (var variableKeyB in fr.exposedNodeVariables[exposedNodeKey].Keys)
                                                {
                                                    if (variableKeyB.Equals(_newName))
                                                    {
                                                        _nameAlreadyExists = true;
                                                    }
                                                }

                                                if (!_nameAlreadyExists)
                                                {
                                                    var _nodeVariableField = fr.graph.exposedNodeVariables[exposedNodeKey].variables[_fromName].nodeOwner.GetType().GetField(fr.graph.exposedNodeVariables[exposedNodeKey].variables[_fromName].name);
                                                    var _nodeVariable      = _nodeVariableField.GetValue(fr.graph.exposedNodeVariables[exposedNodeKey].variables[_fromName].nodeOwner) as FRVariable;

                                                    _nodeVariable.exposedName = _newName;


                                                    fr.exposedNodeVariables[exposedNodeKey].UpdateKey(_fromName, _newName);
                                                    fr.graph.exposedNodeVariables[exposedNodeKey].variables.UpdateKey(_fromName, _newName);
                                                }
                                                else
                                                {
                                                    _exposedVariable.exposedName = _fromName;
                                                }
                                            }

                                            GUI.enabled = true;

                                            if (GUILayout.Button(cancelIcon, GUILayout.Width(20), GUILayout.Height(20)))
                                            {
                                                fr.exposedNodeVariables[exposedNodeKey][_variableKey].exposedName     = _variableKey;
                                                fr.exposedNodeVariables[exposedNodeKey][_variableKey].editExposedName = false;
                                            }
                                        }
                                        else
                                        {
                                            if (GUILayout.Button(editIcon, GUILayout.Width(20), GUILayout.Height(20)))
                                            {
                                                fr.exposedNodeVariables[exposedNodeKey][_variableKey].editExposedName = true;
                                            }
                                        }

                                        if (fr.exposedNodeVariables[exposedNodeKey].ContainsKey(_variableKey))
                                        {
                                            GUILayout.Label("Value: ", GUILayout.Width(50));
                                            fr.exposedNodeVariables[exposedNodeKey][_variableKey].Draw(true, null);
                                        }


                                        //GUILayout.Label("Runtime access: GetData<" + fr.exposedNodeVariables[exposed].variables[variableKeys[s]].GetType().ToString() + ">(");
                                    }
                                }
                            }

                            i++;
                        }
                    }
                }
            }

            ////////////////////////////
            #endregion


            #region sceneoverrides
            // BLACKBOARD SCENE OVERRIDES
            ////////////////////////////
            if (fr.graph.blackboards != null && fr.graph.blackboards.Keys.Count > 0)
            {
                EditorHelpers.DrawUILine();

                using (new GUILayout.HorizontalScope("Toolbar"))
                {
                    GUILayout.Label("Blackboard scene overrides", "boldLabel");
                }

                using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
                {
                    foreach (var bb in fr.graph.blackboards.Keys)
                    {
                        if (fr.graph.blackboards[bb].blackboard == null)
                        {
                            EditorGUILayout.HelpBox("Blackboard is empty, please assign a blackboard asset to the graph", MessageType.Warning);
                            continue;
                        }

                        using (new GUILayout.HorizontalScope(FlowReactorEditorStyles.overflowButton))
                        {
                            fr.graph.blackboards[bb].foldout = EditorGUILayout.Foldout(fr.graph.blackboards[bb].foldout, fr.graph.blackboards[bb].blackboard.name);
                        }

                        if (fr.graph.blackboards[bb].foldout)
                        {
                            foreach (var key in fr.graph.blackboards[bb].blackboard.variables.Keys)
                            {
                                FRVariable value = null;

                                // object is in the scene but variable is not set as overridable
                                if (fr.overrideSceneVariables.TryGetValue(key.ToString(), out value) && !IsObjectPrefabInProject())
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        EditorGUI.BeginChangeCheck();

                                        if (fr.graph.blackboards[bb].blackboard.variables[key].sceneReferenceOnly)
                                        {
                                            GUI.enabled            = false;
                                            value.overrideVariable = true;
                                        }
                                        value.overrideVariable = GUILayout.Toggle(value.overrideVariable, "Override", GUILayout.Width(100));
                                        GUI.enabled            = true;

                                        if (value.overrideVariable == false)
                                        {
                                            //fr.overrideSceneVariables.Remove(key.ToString());

                                            GUI.enabled = false;
                                            GUILayout.Label(fr.graph.blackboards[bb].blackboard.variables[key].name);

                                            if (fr.graph.blackboards[bb].blackboard.variables[key].useDatabox)
                                            {
                                                GUILayout.Label(fr.graph.blackboards[bb].blackboard.variables[key].databoxID + " | " +
                                                                fr.graph.blackboards[bb].blackboard.variables[key].tableID + " | " +
                                                                fr.graph.blackboards[bb].blackboard.variables[key].entryID + " | " +
                                                                fr.graph.blackboards[bb].blackboard.variables[key].tableID);
                                            }
                                            else
                                            {
                                                fr.graph.blackboards[bb].blackboard.variables[key].Draw(true, null);
                                            }
                                            GUI.enabled = true;
                                        }
                                        else
                                        {
                                            GUI.enabled = true;
                                            //GUILayout.Label(value.name);
                                            GUILayout.Label(fr.graph.blackboards[bb].blackboard.variables[key].name);
                                            value.Draw(true, null);
                                        }


                                        GUI.enabled = true;

                                        if (EditorGUI.EndChangeCheck() && !Application.isPlaying)
                                        {
                                            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                                        }
                                    }
                                }
                                // object lives in the scene
                                else
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        var v = fr.graph.blackboards[bb].blackboard.variables[key] as FRVariable;

                                        if (!IsObjectPrefabInProject())
                                        {
                                            if (v.sceneReferenceOnly)
                                            {
                                                GUI.enabled        = false;
                                                v.overrideVariable = true;
                                            }
                                        }
                                        else
                                        {
                                            GUI.enabled = false;
                                        }
                                        v.overrideVariable = GUILayout.Toggle(v.overrideVariable, "Override", GUILayout.Width(100));
                                        GUI.enabled        = true;

                                        if (v.overrideVariable)
                                        {
                                            // create new item and copy it to the override variables
                                            var _newOverrideVariable = (FRVariable)Activator.CreateInstance(fr.graph.blackboards[bb].blackboard.variables[key].GetType());
                                            _newOverrideVariable.overrideVariable = true;
                                            _newOverrideVariable.name             = v.name;

                                            fr.overrideSceneVariables.Add(key.ToString(), _newOverrideVariable);
                                            fr.overrideSceneVariables[key.ToString()].overrideVariable = true;
                                            fr.overrideSceneVariables[key.ToString()].name             = v.name;

                                            v.overrideVariable = false;                                            // blackboard is always false
                                        }


                                        GUI.enabled = false;
                                        GUILayout.Label(v.name);
                                        if (fr.graph.blackboards[bb].blackboard.variables[key].useDatabox)
                                        {
                                            GUILayout.Label(fr.graph.blackboards[bb].blackboard.variables[key].databoxID + " | " +
                                                            fr.graph.blackboards[bb].blackboard.variables[key].tableID + " | " +
                                                            fr.graph.blackboards[bb].blackboard.variables[key].entryID + " | " +
                                                            fr.graph.blackboards[bb].blackboard.variables[key].tableID);
                                        }
                                        else
                                        {
                                            fr.graph.blackboards[bb].blackboard.variables[key].Draw(true, null);
                                        }
                                        GUI.enabled = true;
                                    }
                                }
                            }

                            GUILayout.Space(10);
                            EditorHelpers.DrawUILine();
                        }


                        // cleanup override variables if they don't exist in the blackboard anymore
                        foreach (var kc in fr.overrideSceneVariables.Keys)
                        {
                            bool _overrideVarExists = false;
                            foreach (var bc in fr.graph.blackboards.Keys)
                            {
                                if (fr.graph.blackboards[bc].blackboard.variables.ContainsKey(Guid.Parse(kc)))
                                {
                                    _overrideVarExists = true;
                                }
                            }
                            if (!_overrideVarExists)
                            {
                                Debug.Log("cleanup");
                                cleanupKeys.Add(kc.ToString());
                            }
                        }
                    }
                }
            }

            for (int c = 0; c < cleanupKeys.Count; c++)
            {
                                #if FLOWREACTOR_DEBUG
                Debug.Log("remove override variable " + cleanupKeys[c]);
                                #endif
                Debug.Log("remove");
                fr.overrideSceneVariables.Remove(cleanupKeys[c]);
            }

            // only for debug
                        #if FLOWREACTOR_DEBUG
            DrawDefaultInspector();
                        #endif

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


            serializedObject.Update();
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 7
0
        public void DrawDefaultGUI(GraphEditor _editor, EventBoard _eventBoard)
        {
            if (editorSkin == null)
            {
                editorSkin = EditorHelpers.LoadSkin();
            }

            if (settings == null)
            {
                settings = FREditorSettings.GetOrCreateSettings();
            }

            using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
            {
                GUILayout.Label("Event name:");

                using (new GUILayout.HorizontalScope())
                {
                    newEventName = GUILayout.TextField(newEventName);

                    if (GUILayout.Button("Add Event"))
                    {
                        if (_eventBoard.events == null)
                        {
                            _eventBoard.events = new FlowReactor.OrderedDictionary.OrderedDictionary <Guid, EventBoard.Event>();
                        }

                        _eventBoard.AddNewEvent(newEventName);
                        newEventName = "";
                    }
                }
            }

            if (_eventBoard.events == null)
            {
                return;
            }
            if (_eventBoard.events.Keys.Count == 0)
            {
                return;
            }

            var _events       = _eventBoard.events.Keys.ToList();
            var _statsFoldout = new List <bool>(new bool[_events.Count]);



            GUILayout.Label("Events:", "boldLabel");

            EditorHelpers.DrawUILine();

            try{
                for (int e = 0; e < _events.Count; e++)
                {
                    using (new GUILayout.HorizontalScope("toolbar"))
                    {
                        GUILayout.Space(10);
                        _eventBoard.events[_events[e]].foldout = EditorGUILayout.Foldout(_eventBoard.events[_events[e]].foldout, _eventBoard.events[_events[e]].name);

                        if (e > 0)
                        {
                            if (GUILayout.Button("▲", "toolbarButton", GUILayout.Width(20)))
                            {
                                var _e = _eventBoard.events[_events[e]];
                                _eventBoard.events.RemoveAt(e);
                                _eventBoard.events.Insert(e - 1, _events[e], _e);
                            }
                        }

                        if (e < _events.Count - 1)
                        {
                            if (GUILayout.Button("▼", "toolbarButton", GUILayout.Width(20)))
                            {
                                var _e = _eventBoard.events[_events[e]];
                                _eventBoard.events.RemoveAt(e);
                                _eventBoard.events.Insert(e + 1, _events[e], _e);
                            }
                        }

                        if (GUILayout.Button("x", "toolbarButton", GUILayout.Width(20)))
                        {
                            _eventBoard.events.Remove(_events[e]);
                        }
                    }

                    if (_eventBoard.events[_events[e]].foldout)
                    {
                        using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
                        {
                            var _noCallEventNodes     = false;
                            var _noEventListenerNodes = false;
                            if (_eventBoard.events[_events[e]].callEventNodes != null)
                            {
                                if (_eventBoard.events[_events[e]].callEventNodes.Count == 0)
                                {
                                    _noCallEventNodes = true;
                                }
                            }
                            else
                            {
                                _noCallEventNodes = true;
                            }

                            if (_eventBoard.events[_events[e]].listenerEventNodes != null)
                            {
                                if (_eventBoard.events[_events[e]].listenerEventNodes.Count == 0)
                                {
                                    _noEventListenerNodes = true;
                                }
                            }
                            else
                            {
                                _noEventListenerNodes = true;
                            }

                            if (_noCallEventNodes && _noEventListenerNodes)
                            {
                                EditorGUILayout.HelpBox("Event is not being used in any graph", MessageType.Warning);
                            }

                            using (new GUILayout.HorizontalScope())                     //editorSkin.GetStyle("Box")))
                            {
                                //GUILayout.Label("Event:");
                                _eventBoard.events[_events[e]].name = GUILayout.TextField(_eventBoard.events[_events[e]].name);

                                if (Application.isPlaying)
                                {
                                    if (GUILayout.Button("Call Event", "miniButton"))
                                    {
                                        _eventBoard.events[_events[e]].Raise(null);
                                    }
                                }

                                //if (GUILayout.Button("x", GUILayout.Width(20)))
                                //{
                                //	_eventBoard.events.Remove(_events[e]);
                                //}
                            }

                            using (new GUILayout.HorizontalScope())
                            {
                                GUILayout.Space(20);

                                using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
                                {
                                    if (GUILayout.Button("Add Parameter", "miniButton"))
                                    {
                                        if (_eventBoard.events[_events[e]].parameters == null)
                                        {
                                            _eventBoard.events[_events[e]].parameters = new FlowReactor.OrderedDictionary.OrderedDictionary <Guid, FRVariable>();
                                        }

                                        var menu = new GenericMenu();

                                        foreach (var key in variableSceneTypes.Keys)
                                        {
                                            var _data = new GenericMenuData();
                                            _data.type              = variableSceneTypes[key];
                                            _data.selected          = e;
                                            _data.typeName          = key;
                                            _data.currentEventBoard = _eventBoard;
                                            menu.AddItem(new GUIContent(key), false, AddVariableCallback, _data);
                                        }

                                        menu.ShowAsContext();
                                    }

                                    if (_eventBoard.events[_events[e]].parameters != null)
                                    {
                                        foreach (var p in _eventBoard.events[_events[e]].parameters.Keys)
                                        {
                                            using (new GUILayout.HorizontalScope())
                                            {
                                                GUILayout.Label(_eventBoard.events[_events[e]].parameters[p].typeName, GUILayout.MaxWidth(100));

                                                _eventBoard.events[_events[e]].parameters[p].name = GUILayout.TextField(_eventBoard.events[_events[e]].parameters[p].name);



                                                if (GUILayout.Button("x", "miniButton", GUILayout.Width(20)))
                                                {
                                                    _eventBoard.events[_events[e]].parameters.Remove(p);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            using (new GUILayout.HorizontalScope())
                            {
                                GUILayout.Space(20);
                                _eventBoard.events[_events[e]].connectedNodeFoldout = EditorGUILayout.Foldout(_eventBoard.events[_events[e]].connectedNodeFoldout, "Connected nodes");
                            }
                            if (_eventBoard.events[_events[e]].connectedNodeFoldout)
                            {
                                using (new GUILayout.HorizontalScope())
                                {
                                    GUILayout.Space(20);
                                    DrawMap(_editor, _eventBoard, _events[e]);
                                }
                            }
                        }
                    }

                    //if (Application.isPlaying && _eventBoard.events[_events[e]].eventListeners != null)
                    //{
                    //	_statsFoldout[e] = EditorGUILayout.Toggle("Stats", _statsFoldout[e]);
                    //	if (_statsFoldout[e])
                    //	{
                    //		using (new GUILayout.VerticalScope())
                    //		{
                    //			GUILayout.Label("Listeners registered to " + _eventBoard.events[_events[e]].name + " :", "boldLabel");

                    //			if (_eventBoard.events[_events[e]].eventListeners != null)
                    //			{
                    //				GUILayout.Label("Listener count: " + _eventBoard.events[_events[e]].eventListeners.Count.ToString());
                    //			}

                    //			for (int l = 0; l < _eventBoard.events[_events[e]].eventListeners.Count; l ++)
                    //			{
                    //				//GUILayout.Label(l.ToString() + " : " + eventBoard.events[_events[e]].eventListeners[l]);
                    //				GUILayout.Label(l.ToString() + " : " + _eventBoard.events[_events[e]].eventListeners[l].graphOwner.name + " - " + _eventBoard.events[_events[e]].eventListeners[l].name);
                    //			}

                    //			if (_eventBoard.events[_events[e]].eventComponentListeners != null)
                    //			{
                    //				GUILayout.Label("-----");
                    //				GUILayout.Label("Scene listeners", "boldLabel");

                    //				GUILayout.Label("Listener count: " + _eventBoard.events[_events[e]].eventComponentListeners.Count.ToString());


                    //				for (int l = 0; l < _eventBoard.events[_events[e]].eventComponentListeners.Count; l ++)
                    //				{
                    //					GUILayout.Label(l.ToString() + " : " + _eventBoard.events[_events[e]].eventComponentListeners[l].name);
                    //				}
                    //			}

                    //		}
                    //	}
                    //}
                }
            }
            catch
            {
            }

            EditorUtility.SetDirty(_eventBoard);
        }
Esempio n. 8
0
        public static NodeCategoryTree CollectNodes()
        {
            collectedNodes = new NodeCategoryTree();

            var _found = System.AppDomain.CurrentDomain.FlowReactorGetAllDerivedTypes(typeof(Node));

            //System.Type[] _types = System.Reflection.Assembly.GetExecutingAssembly().GetTypes();
            //System.Type[] _found = (from System.Type type in _types where type.IsSubclassOf(typeof(Node)) select type).ToArray();


            List <CollectedNodesData> collected = new List <CollectedNodesData>();

            for (int i = 0; i < _found.Length; i++)
            {
                NodeAttributes _nodeAttributes = System.Attribute.GetCustomAttribute(_found[i], typeof(NodeAttributes)) as NodeAttributes;

                if (_nodeAttributes != null)
                {
                    collected.Add(new CollectedNodesData(
                                      _found[i].Name.ToString(),           // Title
                                      _found[i].Name.ToString(),           // type name
                                      _found[i].Namespace,
                                      _nodeAttributes.category,
                                      _nodeAttributes.description,
                                      _nodeAttributes.color,
                                      _nodeAttributes.outputSlotCount,
                                      _nodeAttributes.nodeOutputs,
                                      _nodeAttributes.nodeType));
                }
            }

            // Sort by categories
            collected = collected.OrderBy(c => c.category).ToList();

            // Add favorit nodes
            var _settings = (FREditorSettings)FREditorSettings.GetOrCreateSettings();

            if (_settings.favoredNodes == null)
            {
                _settings.favoredNodes = new List <NodeCategoryTree.NodeData>();
            }

            for (int f = 0; f < _settings.favoredNodes.Count; f++)
            {
                collected.Insert(0, new CollectedNodesData
                                 (
                                     //_settings.favoredNodes[f].name,
                                     _settings.favoredNodes[f].title,
                                     _settings.favoredNodes[f].typeName,
                                     _settings.favoredNodes[f].nameSpace,
                                     "Favorites",
                                     _settings.favoredNodes[f].description,
                                     _settings.favoredNodes[f].color,
                                     _settings.favoredNodes[f].outputSlotCount,
                                     _settings.favoredNodes[f].nodeOutputs,
                                     _settings.favoredNodes[f].nodeType

                                 ));
            }

            for (int c = 0; c < collected.Count; c++)
            {
                var _child = collectedNodes.BuildTree(collected[c].category, collected[c].name);

                _child.AddNode
                (
                    //collected[c].name,
                    collected[c].title,
                    collected[c].typeName,
                    collected[c].nameSpace,
                    collected[c].category,
                    collected[c].description,
                    collected[c].color,
                    collected[c].outputCount,
                    collected[c].nodeOutputs,
                    collected[c].nodeType
                );
            }

            return(collectedNodes);
        }