Giter VIP home page Giter VIP logo

xnode's People

Contributors

apkd avatar baranpirincal avatar carlotes247 avatar creativitry avatar deepwolf413 avatar favoyang avatar fernando-toigo-hoplon avatar golfnorth avatar gpoole avatar guizix avatar igorvasiak avatar jzapdot avatar kajed82 avatar koalahao avatar kurtgokhan avatar lumosx avatar lupusinferni315 avatar mowfaqalarbi avatar mytnb avatar needsloomis avatar neoneper avatar noisecrime avatar nostek avatar ravagames avatar rthery avatar siccity avatar tasta avatar thundernerd avatar tmorgner avatar vvoland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xnode's Issues

Improve performance and reduce memory allocations

Hey there
xNode is a really nice framework as it is simple to use and overall very feature complete. However, what really bugs me is its terrible memory management. So this is really more of a feature request than a bug or issue.

In my specific case, xNode is used as an ingame state machine, meaning that I will check connections and flows on runtime. There are nodes for states, and conditions -> You can link states through conditions to other states. If the conditions are met, the game can switch from one state to another. In my case, I iterate through all nodes every frame, to update all condition nodes and check, if the game state is able to change. Why every frame? Well, an other method would be, to build up a whole reactive system that informs every node whenever something relevant changes in the game, and checks if a state could potentially change. This is a hell lot of work and leads to a really confusing reference mess (what informs what and when).
So, the 'Update()' approach it is.

I mean, iterating over some lists of objects to get specific data every frame is not that uncommon and if done correctly, does not cause any heavy heap allocations (cache and buffering variables). Furthermore, I iterate only if necessary.
But sadly xNode does not agree with me on this. The logic for evaluating connections and getting data at node ports performs terrible. The amount of garbage created amazes me. Not really a problem on desktop, but surely on mobile or anything il2cpp based.

Some examples:

  • Node.GetValue() that I override, forces me to box the value inside a System.Object reference, even if it is value typed and it is called multiple times from the framework. For a big node tree that is evaluated per frame this will create unnecessary allocations. But it is not as bad as...
  • ... e.g. NodePort.GetInputValues(), which creates an object-array and reference-copies in a loop. There are many other methods that use the same approach to iterate through ports and get data which again is always boxed in System.Object containers.
  • There is no method which I could pass a pre-allocated List<T> or something. Stuff gets always re-instantiated and retrieved data is nowhere cached: GetValue() gets called repeatedly every time one of my node checks an input port.

At first, I thought: "Well, at least there are generic methods I can use. Maybe I can avoid boxing when accessing value typed variables.". This is what I've found: 'NodePort.cs - line 142'

public T[] GetInputValues<T>() {
    object[] objs = GetInputValues();
    T[] ts = new T[objs.Length];
    for (int i = 0; i < objs.Length; i++) {
        if (objs[i] is T) ts[i] = (T) objs[i];
    }
    return ts;
}

This is not how generics are supposed to be used.

What really lacks is an other way to access or iterate through nodes. As framework user, I'm forced to call GetInputValue() at some point. Not any collection is exposed (through a property or something) to iterate by myself (*). Also, this is quite the core of the framework -> meaning, to improve and optimize this behaviour, probably a lot of refactoring and rewriting is needed.

These are my two cents, maybe stating some points which are already considered or recorded. I'm currently not able to contribute by myself, but maybe someone is willing to build up from here.

Hopefully I get to make some profiling stats the next few days, which illustrates my descriptions here. I'll report back.

Cheers
Julian

(*) Edit: I correct myself on this -> will investigate the various IEnumerators in Node.cs...

Manual doesn't seem to have a clear example of how to grab information.

Hello, this is a lovely app and thank you for developing it. Reading through the wiki I noticed there is not a clear example on how one might use an xNode for their project.

What I mean specifically is lets say I have a monobehaviour, how would I get the info of MathGraph node? The only way I know how to get the info is by:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ExampleComponent : MonoBehaviour
{
        // Attach MathGraph scriptable object here.
	public XNode.Examples.MathGraph example;
        
        void Start ()
        {
                foreach (var node in example.nodes)
                {
                        if (node is XNode.Examples.MathNodes.DisplayValue)
                        {
                                var displayNode = (XNode.Examples.MathNodes.DisplayValue) node;
                                Debug.Log(displayNode.GetValue());
                        }
                }
        }
}

The other option I suppose is linking the DisplayValue scriptable object directly to the monobehaviour. Additionally I believe the example project Dialogue, unless I missed something, has no Unity Scene example, and you have to use what you know to try to recreate the screenshot. I personally think a project showing the developers intention on how this would be integrated with MonoBehaviours would be of great help. Thanks either way, this is a really nice gift for the Unity Community.

Node.graph still points to prefab on instantiated NodeGraph

Repro along these lines:
NodeGraph myGraph = Object.Instantiate(prefab);
if (myGraph.nodes[0].graph == prefab) Debug.LogError("ERR");
else Debug.Log("OK");

I was able to work around this via:
foreach (Node n in myGraph.nodes)
{
if (n != null)
n.graph = myGraph;
}

Adding xNode in Plugins folder

When extracting xNode to the Plugins folder, the Inputs/Outputs doesn't get recognised.

Moving the folder from Plugins to root fixes it, and moving it back brings back the problem.

-Simon

Nodes not deleted in OnDestroy()

NodeGraph instantiates nodes but does not destroy them when it is deleted.

Fix:
public void OnDestroy()
{
for (int i = 0; i < nodes.Count; i++)
{
Destroy(nodes[i]);
}
Clear();
}

NodeEditorAction eats hotControl

Issue:
It seems that NodeEditorAction (NEA) is eating the hotControl before the button click is registered.

I've narrowed it down to the below section of NEA, specifically setting the hotControls to zero, but I don't know how to properly fix it myself without potentially breaking something else:

else if (!IsHoveringNode) {
	// If click outside node, release field focus
	if (!isPanning) {

		// I've got no idea which of these do what, so we'll just reset all of it.
		GUIUtility.hotControl = 0;
		GUIUtility.keyboardControl = 0;
		EditorGUIUtility.editingTextField = false;
		EditorGUIUtility.keyboardControl = 0;
		EditorGUIUtility.hotControl = 0;
	}
	if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
}

Situation:
I'm trying to add a global controls box in the corner of the xNode window using my graph's custom editor's OnGUI.

unknown

Example implementation: https://github.com/dashrava/xNode/tree/hotControlIssue
(Usage: Open graph.asset, try to press button before and after panning.)

Relevant code bit:

[CustomNodeGraphEditor(typeof(NewNodeGraph))]
public class NewNodeGraphEditor : NodeGraphEditor
{

    public override void OnGUI()
    {
        base.OnGUI();

        if (GUILayout.Button("this button doesn't log anything unless you pan or modify NEA"))
        {
            Debug.Log("CLICK");
        }
    }
}

Further information:
I tried to call use() on the current event when the graph editor's OnGUI button is clicked, but it seems that NEA has priority and clears the control before the button click goes through properly.

The control box buttons (used to zoom in the below gif) work after panning:
nea

Considerations:
Is it necessary to reset the hotControl in the first place?

The control box obviously isn't IsHoveringNode.
Is there a way to check that the click is specifically on the editor's background?

Node gets selected though it is overdrawn with toolbar GUI

The toolbar (drawn in overriden OnGUI of custom NodeGraphEditor) doesn't receive click event when there is a node header drawn underneath it and also this node becomes selected.

bug

Toolbar code:

public override void OnGUI() {
    EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
    if (IT.MainNode != null) {
        if (GUILayout.Button("Manual update", EditorStyles.toolbarButton)) {
            IT.MainNode.Generate();
        }
        IT.AutoUpdate = GUILayout.Toggle(IT.AutoUpdate, "Auto update");
        GUILayout.Label(new GUIContent("Selected generator: " + IT.MainNode.name));
    } else {
        GUILayout.Label(new GUIContent("Please select generator!"));
    }            
    GUILayout.EndHorizontal();
}

New node gets added after task-switching

System: macOS 10.13.4, Unity 2018.1b12, b13.
Version of xNode: 1.3 package.

When a node is selected in a graph an extra node is added when I cmd-tab back to Unity after doing something in any other app. Reproducible every time like this:

  1. Make custom graph class.
  2. Make custom node class.
  3. Create graph.
  4. Add node to it.
  5. Select node.
  6. Switch away from Unity and back.

Index out of bounds exception when disconnecting nodes

Steps to reproduce

  • In a class that extends Node, implement OnCreateConnection
        public override void OnCreateConnection(NodePort from, NodePort to)
        {
            base.OnCreateConnection(from, to);
            if (from.ValueType != to.ValueType)
            {
                from.Disconnect(to);
            }
            
        }
  • Connect nodes of two different types and error occurs.

In NodePort GetReroutePoints(int index) add a check for a non-negative index

Use backing value by default on input nodes...

Returning the backing value as default when an Input node is not connected seems better. Right now you can do it by providing the backing value as the default value, but it's an extra step on every field.

Example Now:
GetInputValue("Health", Health)

Example better:
GetInputValue("HealthDelta") // Automatically returns backing value, which would be default< T > anyway.

Is it an issue with performance, or could the backing values be stored in the data cache? I haven't looked at what the performance issues would be.

Unity Crashes On Loop

Whenever there is a loop created in the Math graph example, Unity crashes. I use unity 2018.1.1f1 on a Mac. I think it would be better if the system could detect the loop and not allow it.

Self linking in RuntimeMathGraph Example crashes Unity / App

I'll continue to look at this in the debugger, but if I attach a node output to an input on the same node in RuntimeMathGraph (either in Unity editor or a built application) it crashes. It isn't from the Destroy() call in UGUIPort.OnEndDrag, but I haven't been able to find anywhere else to break in the xNode code between that and the crash.

OS X, several versions of Unity.

ArgumentException: Getting control 0's position in a group with only 0 controls when doing mouseUp

I started to have this bug so I updated to today version of git but still have this error when moving a node.

ArgumentException: Getting control 0's position in a group with only 0 controls when doing mouseUp
Aborting
at UnityEngine.GUILayoutGroup.GetNext () [0x0009d] in C:\buildslave\unity\build\Modules\IMGUI\LayoutGroup.cs:117
at UnityEngine.GUILayoutUtility.BeginLayoutArea (UnityEngine.GUIStyle style, System.Type layoutType) [0x0004d] in C:\buildslave\unity\build\Modules\IMGUI\GUILayoutUtility.cs:361
at UnityEngine.GUILayout.BeginArea (UnityEngine.Rect screenRect, UnityEngine.GUIContent content, UnityEngine.GUIStyle style) [0x00011] in C:\buildslave\unity\build\Modules\IMGUI\GUILayout.cs:287
at UnityEngine.GUILayout.BeginArea (UnityEngine.Rect screenRect) [0x0000c] in C:\buildslave\unity\build\Modules\IMGUI\GUILayout.cs:275
at XNodeEditor.NodeEditorWindow.DrawNodes () [0x00303] in C:\GitLab\sp1\Assets\xNode\Scripts\Editor\NodeEditorGUI.cs:342
at XNodeEditor.NodeEditorWindow.OnGUI () [0x00070] in C:\GitLab\sp1\Assets\xNode\Scripts\Editor\NodeEditorGUI.cs:26
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in :0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0
at UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) [0x00013] in C:\buildslave\unity\build\Editor\Mono\HostView.cs:295
at UnityEditor.HostView.Invoke (System.String methodName) [0x00009] in C:\buildslave\unity\build\Editor\Mono\HostView.cs:288
at UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) [0x0011f] in C:\buildslave\unity\build\Editor\Mono\HostView.cs:261
at UnityEditor.DockArea.OldOnGUI () [0x0055b] in C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:390
at UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, System.Boolean isComputingLayout) [0x001cc] in C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:237
at UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) [0x0002f] in C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:380
at UnityEngine.Experimental.UIElements.IMGUIContainer.HandleEvent (UnityEngine.Experimental.UIElements.EventBase evt) [0x00082] in C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:359
at UnityEngine.Experimental.UIElements.EventDispatcher.PropagateEvent (UnityEngine.Experimental.UIElements.EventBase evt) [0x00116] in C:\buildslave\unity\build\Modules\UIElements\EventDispatcher.cs:500
at UnityEngine.Experimental.UIElements.EventDispatcher.DispatchEvent (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel) [0x003ce] in C:\buildslave\unity\build\Modules\UIElements\EventDispatcher.cs:345
at UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) [0x00065] in C:\buildslave\unity\build\Modules\UIElements\UIElementsUtility.cs:243
at UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) [0x00030] in C:\buildslave\unity\build\Modules\UIElements\UIElementsUtility.cs:74
at UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) [0x00012] in C:\buildslave\unity\build\Modules\IMGUI\GUIUtility.cs:171

(Filename: Assets/xNode/Scripts/Editor/NodeEditorGUI.cs Line: 342)

This is on 2018.2.0f2, last time I used xNode I was still on 2017.4 and had no problem.

image

hj.

Incorrect value for output node

I have two type of nodes which have an output bool initialized to true. In one of the node I can get the value 'true' and on the other I get 'false'.

    public class InitialOrderNode : MissionNode
    {
        // The value of an output node field is not used for anything, but could be used for caching output results
        [Output] public float TimeSinceStart;

        [Output] public bool TrueValue = true;

        private float TimeSinceLevelStart;

        public override void Execute()
        {
            TimeSinceStart = Time.time - TimeSinceLevelStart;
        }

        public override void Initialize()
        {
            TimeSinceLevelStart = Time.time;
        }

        // GetValue should be overridden to return a value for any specified output port
        public override object GetValue(XNode.NodePort port)
        {

            // Get new a and b values from input connections. Fallback to field values if input is not connected
            switch (port.fieldName)
            {
                case "TimeSinceStart": return TimeSinceStart;
                case "TrueValue": return TrueValue;
            }
            return null;
        }
    }

    public class PlayerNode : MissionNode
    {
        // The value of an output node field is not used for anything, but could be used for caching output results
        [Output] public float Shield;
        [Output] public float Armor;
        [Output] public float ShieldPlusArmor;
        [Output] public bool IsAlive = true;
        [Output] public bool WasDestroyed;
        [Output] public Vector3 Position;

        [Output] public bool IsWarpingOut;
        [Output] public float CurrentThrottle;


        public override void Execute()
        {
        }

        public override void Initialize()
        {
        }


        // GetValue should be overridden to return a value for any specified output port
        public override object GetValue(XNode.NodePort port)
        {

            // After you've gotten your input values, you can perform your calculations and return a value
            switch (port.fieldName)
            {
                case "Shield": return Shield;
                case "Armor": return Armor;
                case "ShieldPlusArmor": return ShieldPlusArmor;
                case "IsAlive": return IsAlive;
                case "WasDestroyed": return WasDestroyed;
                case "Position": return Position;
                case "IsWarpingOut": return IsWarpingOut;
                case "CurrentThrottle": return CurrentThrottle;
            }
            return null;
        }
    }

In the PlayerNode class the IsAlive output is always false while it is true in the InitialOrderNode class.

Node rename

Allow user to rename the node in an intuitive and non-intrusive way.
Possibly by clicking a small icon on the node header, or in the right-click context menu.

Tint color are too dark

You can't tint with bright color. They too dark and you didn't see labels at it.
Colors for backgrounds are inlined and tangled with code, they need to be in settings window at my opinion.

NodeGraph.Copy() will crash on a null node

In NodeGraph.nodes, if there is a null value in that list, NodeGraph.Copy() will crash in the Copy() function. A null value can result from changing the size property in the inspector of the scriptable object. It can also result from deleting a type formerly used.

Fix:

copyFix.txt

Restriction to add a Node

Hello!
Is there a way I can hide my Node from the specified Graph. I have two subsystems: Visual Scripting and AI. I need to make VS nodes appear only in VS graph and AI nodes appear only in AI graph.

Best,
Andrey

Adding attribute NodeWidth

I suggest adding a NodeWidth(int width) attribute.

[SerializeField] [Range(0, 5)] float testfloat = 0f;
Does not get its slider drawn due to the width of the node, expanding it to 450 makes it visible.
But does not make sense for every node, so maybe it should be a attribute.

Ps. Great node editor! :)

Add NodeEditor.OnEnable override

Hi Thor!
I have to do things like:
SerializedProperty serializedProp = serializedObject.FindProperty("prop"); inside OnBodyGUI!
Which is definitely not the best way in terms of performance especially if one needs to do it in a loop.
If OnEnable were exposed, we could just use it for the initialization of the editor values.

Best Regards, Alex

Namespace clash

Using the namespace XNode causes clashes with scripts that use the built in System.Xml.Linq.XNode class. If this was in my own scripts it wouldn't be a big deal, but I'm running into it in 3rd party scripts (in my case scripts associated with Wwise) that I don't want to have to change each time I update the integration. Changing the namespace to something more specific like Siccity.XNode might be advisable to avoid this.

Undefined string in XNode.Node locks up Unity

Having undefined strings may cause XNode and Unity to lock up after a bridging attempt. The XNode window will become unresponsive and the console.log will log null references.

The workaround is to initialise the string variable.

Replication

using UnityEngine;
using XNode;

namespace BasicNodes {

    [System.Serializable]
    public class ProofOfConcept : XNode.Node {

        [Input] public string mystring;
        [Output] public string result;

        public override object GetValue(XNode.NodePort port) {

          result = GetInputValue<string>("mystring", this.mystring);

          return result;

        }

      }
}

Workaround

using UnityEngine;
using XNode;

namespace BasicNodes {

    [System.Serializable]
    public class ProofOfConcept : XNode.Node {

        [Input] public string mystring = "";
        [Output] public string result;

        public override object GetValue(XNode.NodePort port) {

          result = GetInputValue<string>("mystring", this.mystring);

          return result;

        }

      }
}

How to remove invalid node?

StateNode node = target as StateNode;
StateGraph graph = node.graph as StateGraph;
if (graph.current == node) GUI.color = Color.blue;

It's not safe to write this, if I add StateNode on my custom FSMNodeGraph. And I have a problem on how to remove this node in node editor.

Error:

NullReferenceException: Object reference not set to an instance of an object
XNodeEditor.Examples.StateNodeEditor.OnHeaderGUI () (at Assets/xNode/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs:15)
XNodeEditor.NodeEditor.OnNodeGUI () (at Assets/xNode/Scripts/Editor/NodeEditor.cs:21)
XNodeEditor.NodeEditorWindow.DrawNodes () (at Assets/xNode/Scripts/Editor/NodeEditorGUI.cs:365)
XNodeEditor.NodeEditorWindow.OnGUI () (at Assets/xNode/Scripts/Editor/NodeEditorGUI.cs:26)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Runtime Node UI?

From a brief glance I am assuming that there's no support for a runtime graph UI? I'd have to implement that from scratch myself?

Usage from a DLL

As written, version 1.3 can't be used from a DLL. This is the fix:

public static Type[] GetDerivedTypes(Type baseType) { // KevinJ: 3/23/2018 Allow to be used from a DLL List<System.Type> types = new List<System.Type>(); System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly2 in assemblies) { types.AddRange(assembly2.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t) ).ToArray()); } return types.ToArray(); }

Also:

private static void BuildCache() { portDataCache = new PortDataCache(); System.Type baseType = typeof(Node); // KevinJ: 3/23/2018 Allow to be used from a DLL List<System.Type> nodeTypes = new List<System.Type>(); System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assemblies) { nodeTypes.AddRange(assembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t) ).ToArray()); } for (int i = 0; i < nodeTypes.Count; i++) { CachePorts(nodeTypes[i]); } }

Editor window

There is no editor window. Where to start using it ?

Logo Design: xNode

Hello!

I'm a graphic designer and I like to support open source projects. I would like to design a logo for your project if you interested, I will be happy to work with you! :)

Best Regards

Baran Pirinçal

Graphic Designer

Move To Top shouldn’t reorder the node list.

Move to top modifies the node list directly which wreaks havoc when a project is shared between multiple people. Node order should only change when done intentionally. Maintaining a separate list would solve this. Since nodes might also be filtered depending on the implementation it might be useful to have the handler for these behaviours be an interface.

Add node (multi)selection

Add a selection system to xNode.
Implementation should include:

  • Simple, visual indicator on each selected node
  • Box select
  • Context Menu extended support for multi selection
  • Possibly tie together with unity internal selection system

Error when run on Unity 2017.3.0p3

Hi,
I just download the latest code on github and try to create Graph and Node,
But there is an error here:
ArgumentNullException: Argument cannot be null.
Parameter name: collection
System.Collections.Generic.List1[UnityEngine.Object].CheckCollection (IEnumerable1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:435)
System.Collections.Generic.List1[UnityEngine.Object]..ctor (IEnumerable1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:58)
XNodeEditor.NodeEditorWindow.DrawNodes () (at Assets/xNode/Scripts/Editor/NodeEditorGUI.cs:216)
XNodeEditor.NodeEditorWindow.OnGUI () (at Assets/xNode/Scripts/Editor/NodeEditorGUI.cs:23)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:295)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:288)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:255)

DrawDraggedConnection throws error on disconnect

Issue:
I'm creating instance ports and drawing them manually in the node's custom editor for some temporary stuff, and destroying them immediately when disconnected.

Whenever the port is destroyed, or its drawing is stopped, while disconnecting, xNode throws a dictionary error.

Repro:

  1. User begins to disconnect a port by dragging

  2. (a) OnRemoveConnection calls RemoveInstancePort on the port
    or

  3. (b) Custom editor stops drawing the port.

  4. User keeps dragging away from the now-destroyed port

  5. Error: KeyNotFoundException: The given key was not present in the dictionary. thrown by the portConnectionPoints[draggedOutputTarget].center dictionary check in DrawDraggedConnection in NodeEditorAction.cs.

Potential fix:

Add key check to DrawDraggedConnection:
if (draggedOutputTarget != null && !_portConnectionPoints.ContainsKey(draggedOutputTarget)) return;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.