A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
New Unity Live Help updates. Check them out here!
Discussion in 'Assets and Asset Store' started by Siccity, Oct 30, 2017.
Thanks I'll give it a try
Hi Siccity, i have release my utility ai framework based on your awesome xNode. I mainly use it for my projects but i decided to do some documentation for my students.
Of course i credited you.
I added a link to your project in the wiki
Hi. Could you help me?.
How i can add an toolbar menu at graphNode windows?.
I can see in any preentScreen that you do it, but i no can see where there it in your codes.
Is there a super simple example showing the creation of a graph at runtime? I know there is Example scene, but it seems to also support for the Unity Editor component which is something I don't need.
On version 1.7, there is folder "examples", and inside there is a runtime sample.
You can override OnGUI in a custom graph editor and draw it like you normally would
Oyea, i already did that. But the real problem is the zoom. I can not position the Gui in top, because the zoom of the grid reposition the rect of the the gui components. I tried used Guilayout, Gui with rect and calculate de real position using the function GridToWindows and WindowsToGrid too. But not work
So much power, I like it!
Hi again Siccity, do you plan a way to group nodes with larger node with a title ? It could be a life saver for huge graph.
Thx again for you good work mate.
It's been on the roadmap for a very long time, there is even an old proposal pull request on the GitHub page. I haven't gotten around to giving it an implementation yet though. Right now the easiest approach to simplify graphs is to implement sub graphs. Depends a lot on your design though.
I am curious about the run time option and will explore it. I want to create a game for my son. He only wants to play with the plugs as he call them. The idea would be you connect nodes at run-time to spawn an elements such as a platforms, enemies, anything really, and give it a spacing, height offset whatever. He likes Mario maker so it would be cool for him to play with. I know that there are already coding games for kids but i think this would be a little different. I am thinking something like Archimatix but at runtime.
Any idea when an official Odin integration is on the roadmap?
Support has recently been added on a separate branch. It will need some more testing before it is merged into the master branch, so go check it out!
Update! Odin Inspector support has now officially been merged into the main branch!
And xNode is now back to being free again on the Asset Store! For donations I urge you to do so either on my ko-fi page: https://ko-fi.com/Z8Z5DYWA or on my new patreon page: https://www.patreon.com/thorbrigsted. Thanks!
I am pretty new to this, so please forgive if I ask the obvious...:
a) is there a tool that helps reduce time needed to create prefabs for nodes (runtime nodes). I can reverse engineer how to do it quickly, but there are many scripts that need to be rehooked etc. to make even a simple node work runtime.
b) how do I control execution when in editor mode - on what input events it re-evaluates? Can I pause/unpase/force evaluation?
c) suppose I don't want my graph network to "do the job" on target gameobjects, but rather generate a recipe in a form let's say of a scriptable object. Where to start with that?
xNode is not built with runtime graph editor in focus. there are other free node editor plugins that focus on this.
I don't think anyone has made a proper "runtime xnode editor" tool.
xNode does not come with any kind of flow. It will 'evaluate' when you ask it to (eg. call GetInputValue)
I'm not sure what you mean with this question. xNode graphs always exist in ScriptableObjects
@Siccity thank you very much. All clear. My main concern with evaluation was that when using editor nodes (regular nodes), I observed the entire graph is evaluated multiple times when I hover over node's output. I guess this is Unity related stuff. I am wondering how to make it evaluate on request only.
About alternatives - I am looking strictly for a solution tailored for runtime graph editing. Do you by any chance know whether Node Editor Framework is simpler to setup for runtime mode?
Hover tooltips get their information from calling GetValue on the hovered port, so if your GetValue triggers a full graph reevaluation, then yes, it will reveluate.
An fix to this would be to have GetValue return a cached value, and only reevaluate when values change. This also will improve your performance a lot in the long run.
If runtime editing is what you're after, you'll probably have an easier time using NEF, yeah.
@Siccity I am much obliged for help!
@Siccity This is an awesome project and I hope to contribute(github), I have a visualizer using the node graph, so hopefully can give some pull requests coming up.
> I don't think anyone has made a proper "runtime xnode editor" tool.
I want to work on this down the road, especially making it available in WebGL.
Do you by any chance have some runtime UI wrapper for Xnode?
> Do you by any chance have some runtime UI wrapper for Xnode?
Yes but I am at the state where I am developing an app with it right now. That said, time is always the issue but basically an adapter for the xNode API into the graph rendering at runtime.
So.. for safety, xNode is the compile time serializer, runtime deserializes and use that model, but could be any other model with an adapter to draw a graph. This is complicated, so I don't want to think I am not going to run into things trying to keep the abstraction.
@TeotiGraphix is there a way to intercept input events (like mouse wheel etc..) so I can override them with mines?
The use case is for example a zoom (using mouse wheel) on an image contained inside a node. (and I don't want the graph to zoom as well)
Off the top of my head, I don't know. The editor API is so crusty, I would actually have to try and figure this out myself to give you an answer, so I don't know at this time.
I had to modify NodeEditorGUI.cs code
Maybe you could just add a property to enable/disable input like this?
Hi, I was wondering how to go about creating a manager to paras through each node starting from a start node then going through each input-output till it reaches an end node.
for instance I have a start node that leads to a string node, all nodes have a function named ONTrigger(), which will do a specific thing when triggered....In my graph I have the start node then 3 string nodes. I just need it to look through each node in sequence and then trigger the ONTrigger() function.
if Someone could point me in the right direction, would be a huge help. Thanks in advance.
Check out the examples
So I picked this up for making AI. I understand how to make node and graph classes. But how do you evaluate the graph? Is there no way other than making and calling a function on the graph class that loops through all the nodes in the graph, does a conditional check and evaluates them?
Is there no way to specify a function that traverses the necessary nodes in the graph to return an output from the final node or do I need to write my own logic for that?
What I want to do is the following:
1. Have a blackboard of sorts for holding external variables. Like player position and stuff that will change in runtime. I can pass those in as parameters in the evaluation function of the graph class. But how do I feed those parameters to the nodes to produce outputs? And these parameters would likely be different for each enemy instance.
2. Evaluate only the necessary nodes to reach a certain output node. I could loop through the entire graph but the problem with that is the nodes might need to be evaluated in a certain order. I could run something like DFS to find that path I guess but I'd still need to cache it somehow.
Would Node Editor Framework be better in this case since it supports traversals(I haven't looked into it).
There are a million different ways to traverse a graph, all dependant on your needs. For this reason, xNode does not come with built-in traversal. A common way of doing it is start by looping through your node list and find your start (or end) node, and trigger (or request output from) that. Your trigger method should evaluate your node as well as trigger the next nodes in the chain.
I recommend looking at the examples.
So I'll need to traverse the list manually. I have some other questions:
1. Any way to mark a node so that I can know if it's a specific node I want when I'm traversing the list (Other than differentiating through typecasting/putting a flag field in the node class)?
2. Can I safely keep refs to a certain node after I've found it?
3. Is it possible find which nodes a node's input port is connected to?
4. When I evaluate a node do I automatically evaluate the ones the node's input ports are connected to beforehand? Or do I need to evaluate those nodes first somehow.
No. A bool flag is fine.
Sure. Just make sure to cache values in non serialized fields, as ScriptableObjects are not cleared in editor.
Yes. Completely the same approach as for outputs. GetPort("myInput").GetConnection
You can evaluate just however you want. xNode does not interfere with your evaluation process
@Siccity Thanks for the clarifications. I swear this'll be my last question.
My question is less about xNode specifically and more about scriptable objects. What's the best way to handle instance variables? Say I want to use the same AI graph I made for different enemy instances. Since all enemies have the same Scriptable object they'll all be modifying the same variable. Which is not good if I want something like a cooldown timer.
The simplest solution would be to keep a dictionary with enemy references as keys and field as values. Any thoughts?
Each AI can perform a graph.Copy() on start to create its own deep copy of the AI graph to run in. This way you avoid ever getting your graph altered from external sources too.
Is there any way to make the node looks like the one in behavior designer? I'm planing to write an visual editor for my behavior tree but I couldn't find any node api like the one below.
You can skin nodes freely and use angled connections, but vertical connections are not yet supported.
Hey I would like to thank you for having this available it has really helped out a project that I've been working on I just have one question. Its how to make the objects for condition checking on the branch node. I cant really seem to find a clear example of what to do or what is needed if there's a way I will be forever grateful.
I would like to know how can I connect an ingame (not a prefab) gameobject with the node as an input.
Thank You in advance.
Quick question, I have a simple test NodeGraph which has 4 nodes in it, from my game I get the NodeList from the NodeGraph object so I can run through the nodes and build a custom system from it. The count on the nodes is 5 though instead of 4 and if I just try and print the name of each node I get an exception when I try and access the 5th item, why does the nodes list hold 5 items when there are only 4 nodes in my graph?
Another quick question are the nodes in any kind of order in the list or just the order they were added? Is there a way an API way to get the root object and run through the children or do I just use the Ports values and build it myself?
Nodes are ScriptableObjects. ScriptableObjects can't reference scene objects. You have to use an ID system to get gameobject references.
This can happen if a script was deleted or renamed outside Unity, or something else went wrong and Unity can no longer find the class associated with the node. The node becomes an invalid scriptableobject and unfortunately there is no way to clean up invalid SO sub-assets as they can't be referenced. I did add some asset postprocessing to try and fight this issue, but it only works when removing or adding scripts inside the editor.
The order is just the order they were added. A one-directional order of nodes wouldn't be of much help anyways as graphs can have several roots, branching, loops, etc
If I put a Range() attribute on a value in my node then its very hard to change the value, is there a reason for that, ie if I have an int value and have Range(0, 3) attribute on it next to impossible to get it to change value on the graph.
Without testing it myself, my guess is it has something to do with zoom levels. Zooming with IMGUI sometimes makes odd behaviour with built-in unity drawers. If your minimum zoom is set to 1 and you zoom all the way in, it should behave normally.
Is there a way to have it show the connections going into an input so I can clear just the one I want, at the moment if I have some complex graph with a lot of connections going in out of nodes if I need to reroute one I have to clear all the connections and wire them all up again. It would be nice if I could right click the line and just clear that connection, or is there some functionality I am missing?
Also another issue when I add a new node to the graph that seems to become the root node for everything and all the pre existing nodes are children of it in the project view. Shouldnt the graph remain as the root with all the nodes of it?
Handled that in my system by allowing to save the graph to the scene, if the ScriptableObjects ARE scene-only objects, they can properly reference scene objects. That is not optimal if you plan to use the graph in multiple scenes with different objects each though. Then only an ID system is going to help.
There are some issues with the newer versions of Unity. They changed their asset database to a broken one. An effort to prevent this mixup mas been implemented not too long ago. Are you using the newest version from the master branch?
Thanks for the tip! Will look further into this tomorrow.
Not right now, unfortunately. However, you can 'cycle' through the input connections by clicking the port. Every time you press and hold, the selected connection is highlighted, just keep clicking till the right connection is highlighted.