Coder Social home page Coder Social logo

seneral / node_editor_framework Goto Github PK

View Code? Open in Web Editor NEW
2.0K 160.0 412.0 5.12 MB

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity

Home Page: https://nodeeditor.seneral.dev

License: MIT License

C# 99.80% ShaderLab 0.20%
unity node editor imgui

node_editor_framework's Issues

Example or more thorough documentation regarding events anywhere?

I'm using the Node Editor as tool to modify/move/add/remove components in the Editor (not in play mode). I'd imagine that I want to use the NodeEditorCallbacks class and not the NodeEditorCallbackReceiver one. I understand how to implement the second method, but not the prior. Any examples anywhere?

Multiple trees node calculation

Hi,
I've encountered a problem with Node Editor.
I'm using it to create skill trees. Each node in skill tree is a individual skill, and it can have parent skill (only one) and child skills (multiple). Each time I create a skill tree I store child nodes in a easy accessible List, and I do this in Calculate method.
In project I wish to have multiple skill trees. It is easily done by creating multiple canvases.
Here is sample tree I've created (other 2 trees are similar looking):
screen

I've created a class SkillTreeNode deriving from Node class that framework provides. In SkillTreeNode I've got a
List<SkillTreeNode> childNodes
in which I store all child nodes from Output.
Everything works as charm to that moment. All references are set and it's looking like ready to go.

I've created a class, which I use in runtime, that references all of my skill trees. It's job is to check if a skill is available for player on certain level and if that skill can be used. It uses the childNodes to do this.

But when I do foreach o every element of childNodes, Unity says that there is some elements and every element is null. It is true for all skill trees but the one that was processed (Calculate was called) last.

For example if I got 3 skill trees: 1,2 and 3. If I process skill tree 1, childNodes for every element in that tree will be set properly and there won't be any nulls. But in skill tree 2 and 3 all childNodes will be nulls. If I process skill tree 3, childNodes in that tree will be setup properly, but for trees 1 and 2 they won't.

I'm not sure if it is my fault or something is wrong in framework.

Here's my Calculate method:

public override bool Calculate ()
        {
            Debug.Log("Calculate call on: " + this.skillName);
            childSkills.Clear();
            parentSkill = null;
            if (Inputs[0].connection != null)
            {
                parentSkill = (SkillTreeNode)Inputs[0].connection.body;
                isRootNode = false;
            }

                foreach (var node in Outputs[0].connections)
                {
                    Debug.Log(SkillName + " " + ((SkillTreeNode)node.body).SkillName);
                    childSkills.Add((SkillTreeNode)node.body);
                }
            return true;
        } 

Thanks for any help

GenericMenu in NodeEditor and RuntimeNodeEditor

When I use the NodeEditor window by itself, the contextual menu appears without any issues when pressing the right mouse button.

But, if I put Unity in Play Mode with a RuntimeNodeEditor, the contexual menu of the NodeEditor window doesn't appear anymore.

I looked into the code, but wasn't able to find a clue. :-)

Node creation issues

Hey,

If I open a Node Editor window with an empty canvas the Create method of all my custom Nodes get called. I wonder why this happens on an empty canvas.
If I add a Node by hand (right click => add) the Create method is called as expected. Afterwards the methods Calculate and NodeGUI are called. The problem is that the node.GetInstanceId() is changing between Create and the other methods. This explains why I am loosing references to some custom private members that I set up in the Create method.
Is the Node instance copied somewhere? Is this a bug or the expected behavior?

Sorry if this is not the right place for such questions..

Array based input support

I apologize ahead of time for bugging the contributors again, but any way to handle array based input support? Here's an example using the calc node: I want to have an int input (numInput) that correlates to the number of inputs in an array (inputArray). So if numInput = 2, I can add/multiply inputArray[0] and inputArray[1]. Alternatively, I could make numInput = 5 and do sum(inputArray[0]:inputArray[4]) to get the sum of each integer in the array.

Right now, node creation usually goes in the Create method. I imagined implementing it like so: create an integer input that correlates to the input array size. Then, create/delete inputs whenever that value changes. However, I don't currently see a delete input method. Do you think this approach would work? Or, is there a better solution?

If there's not currently support for this, any direction how I might implement this? As I said, I'm new to open source projects, but willing to try to help out! :)

Old canvases are not usable after upgrading Node_Editor

ScriptableObjects (and so are the nodes) are only ever loadable if they have the same structure than before, otherwise they're silently nulled. Since sometimes between commits the structure of the Node.cs changes and thus old saved canvases stop working.

It's a bit of an abstract issue / feature (also big) to make saves stable but maybe it's worth thinking about?

Infinite Loop in ClearCalculation Function

Unity version: 5.2.1f1

If you make two recursive node (node.allowRecursion = true) and loop them, it will make an infinite loop in ClearCalculation Function in NodeEditor Class and unity will shut down without any log.

this loop is made in NodeEditor.cs:848

First clean Node Editor release

Due to the recent change in the repository management, I think it is suited to finally clean themaster branch. We've already moved the developement stuff to their own respective branches, so we can do this without worries.
To mark the importance of this step, I'll just add a release and milestone to this issue, wish will then be the first (official) one ever.
I've already cleaned a version so far to have removed all current WIP stuff, including the action Node / Unity Func and the state system stuff.

Node_Editor documentation

PDF shouldn't be the only format of distribution for the documentation.
It's hard to edit (only the one - you - with the source file can edit it) and it lacks version control because it is a binary file type.

I think a good alternate way would be to have GitHub pages set up, with the documentation in HTML. The PDF files in this repository would be a "print" of those files.

Duplicate Node (very rarely) causes two nodes to be created

I never had this happen to me, but once I passed the tool off to the content creators, they ran into this issue where 50% of the time, Duplicate Node would create an extra duplicate (two copies). Any idea what might be causing this or how I might fix it?

Clipping for custom runtime Bezier drawing

Description: As handles cannot be used at runtime, I created a bezier drawing function some time ago. It works but currently does not provide clipping (not only for optimisation, but it will extend over bounds).

State: None. To get the bounds to clip to, use GUIScalingUtility.cs, there are properties to get the parent group rect.

Location: RTEditorGUI.cs

Object Browser crashes the node editor

Although it is suggested to only use GUI/GUILayout Elements inside a node, it may prove truly useful to have EditorGUI elements as well such as ObjectField(...). This, of course, is incompatible with runtime editing but it should not prevent unity editor to benefit from EditorGUI capabilities. Some may use this framework purely to create sequence of actions (my case), and never provide a runtime editor.

The control itself works and appear correctly inside the node. Drag'n'Drop function as well. But if you choose to reference object by using the native object browser: The editor goes out of control, loose current edited canvas because of the implemented exception catcher.

Any idea why?

image

After clicking on the bullseye :

image

image

Is it possible to include functionality inside of NodeEditorSaveManager to create new canvas?

I needed to be able to duplicate a node graph to to the same canvas and to a new canvas. I easily figured out how to duplicate a graph to the same canvas quite easily, but in order to duplicate to a new canvas, I need to create one. So I know I can call NodeEditorWindow.NewNodeCanvas() from an editor script, but I want to be able to call it from a node (via a button), which doesn't appear to be able to access editor scripts. What's the best way for me to accomplish this?

Canvas living in scenes

Description: There are cases where you want to adress gameObjects in a scene rather than just assets. For this the canvas (scriptableObject) has to live in that scene. The workflow and some actions might need to be adjusted for that case so a property livesInScene should be added to the Canvas (already added in my testing builds and prepared the ActionNode for this feature implementation).

State: Added bool livesInScene Property to canvas to make functionality of certain stuff ready for this change.
Notes:
To save it in the scene, you do not need to use the NodeEditorSaveManager, just create it and reference it somehwhere in a scene GameObject. Reference here. To load it, give the user a dropdown of all NodeCanvas references in the sceme that are NOT saved as an asset.

Location: NodeEditorWindow.cs (NOT actual framework) and RTNodeEditor.cs

How NodeCanvas ( Nodes with Inputs/Outputs ) should be loaded in Runtime/Compiled

Hi,

I am really happy to discover this gem,
Very nice, very clean & easy to customize.

I just got one main issue,
How to load the NodeCanvas in Compiled game, i.e. to use the nodes logic in the game.

So far I get it to work in UnityEditor through :

NodeCanvas x = NodeEditorFramework.NodeEditorSaveManager.LoadNodeCanvas("Assets/Plugins/Node_Editor/Resources/Saves/"+Conversation.name+".asset");
NodeEditor.RecalculateAll(x);

But that won't work in Compiled versions.

Any advice ?

Thanks

Dynamic Multi-Way Connection System

Right now outputs can always have multiple connections and inputs can only have one connection. It would be nice if this were more flexible and you restrict an output to one connection or allow multiple connections for an input.

Custom (Additional) Save format for Runtime

Description: Current save format, ScriptableObjects, cannot be created and saved at runtime nor saved externally. So, a new save file format for runtime is needed. It should be optional for the Editor but essential for Runtime.
Maybe Binary, but more likely XML, just like Substance's .sbs.

State: None. Along with it there should be an attribute-based tagging system for extra variables that need to be saved in each Node/NodeKnob subtype. The rest is hardcoded as it is known what to save, obviously.
Please notify me before working on this to discuss some details:)

Unable to build after cloning

Hello.

Using a fresh clone of the develop branch into a new unity project, I cannot build this. I am on OSX with Unity 5.3.5f1.

There error is on HotkeyAttribute and EventHandlerAttribute.

screen shot 2016-07-21 at 15 14 09

The quite fix to get it to compile is to make priority read/write by removing the private keyword for priority in the implementation of both HotkeyAttribute and EventHandlerAttribute. However I don't know what the consequences are. I am just trying out Node_Editor.

Cheers,
Ross

Can't load a canvas file in Play mode

When loading a canvas file while in Play mode, nothing appears in the Node Editor.
Adding nodes manually and saving files works normally.

Steps to reproduce:

  1. Start Play mode in Unity
  2. Load Canvas file

OverlayGUI (Popups)

Description: For the Node Editor to properly work at runtime, we need support for all kinds of popups (GenericMenu, EnumPopup, IntPopup, etc., even Tooltip). This will also fix some bugs regarding node focussing problems, as these will not block user input straight away when clicking it (even the first click event). Additionally, this will open up the possibility to let them account for the zooming - respective built-in controls will simply ignore the GUI scaling:/

State: This is easily possible using the Popup Engine I already made for the GenericMenu to work.

Location: OverlayGUI.cs and RTEditorGUI.cs for implementing new popups

Documentation should have installation section

Someone who is new to Unity may not know how to install this (since it is not in the asset store either). A small and brief section in the documentation on how to incorporate Node Editor could be helpful.

Documentation for interfacing programmatically

Currently the documentation is missing how you would plug in/out game states from the node-graph. (I've read the unity forums too, yet I have no clue how I would use this for something like game-logic.)

Any help and additions in the docs would be appreciated.

Additionally to this issue, I would highly recommend ReadTheDocs for auto-parsing documentation from documented classes, making it easy to make a comprehensive documentation for this project.

Statemachine Behaviour support

Description: Integration into the existing calculation system, enables for transitioning though nodes based on conditions like the mecanim statemachine

Progress: With e32476e, the WIP state system has been added. Transitioning behaviour exists, missing are the conditions. This is because any kind of functions cannot be serialized. Currently, I'm creating a workaroung called UnityFunc.

Statemachine Branch

Multi-Selecting Nodes

Description: Selecting, moving, deleting and duplicating multiple nodes.

State: None. May need adjustements to NodeEditorState and the input checking system.

Unity Asset Store

This is not really a bug, more of a wishlist. I came across this project from the forum. I have to say it is impressive and exactly the thing I am looking for. What puzzles me is why it is not in the Unity Asset Store (this is likely the first people go to find things like this!).

Can´t load a canvas file after exiting Play mode

When loading a canvas file after exiting Play mode, nothing appears in the Node Editor and a error is thrown.
It also becomes impossible to add new nodes to the canvas. The solution is to start and stop the Play mode.

Steps to reproduce:

  1. Start Play mode in Unity
  2. Press New Canvas in the Node Editor
  3. Exit Playmode
  4. Load Canvas file

MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. NodeEditorFramework.NodeKnob.GetGUIKnob () (at Assets/Plugins/Node_Editor/Framework/NodeKnob.cs:143)

Having trouble making custom connection types

I'm having trouble implementing custom connection types. The current documentation seemed quite straightforward and simple, but I keep getting an error.

Basically, I need the output of a node to be a custom component reference which I assign in the inspector.

  1. Made Machine Node (assign Machine component in inspector)
    capture

  2. Created ITypeDeclaration Interface
    `
    using UnityEngine;
    using System;

public interface ITypeDeclaration {

string name { get; }
Color col { get; }
string InputKnob_TexPath { get; }
string OutputKnob_TexPath { get; }
Type Type { get; }

}
`

  1. Created MachineType
    `
    using UnityEngine;
    using System;

public class MachineType : ITypeDeclaration {

public string name { get { return "Machine";  } }
public Color col { get { return Color.cyan; } }
public string InputKnob_TexPath  { get { return "Textures/In_Knob.png";  } }
public string OutputKnob_TexPath { get { return "Textures/Out_Knob.png"; } }
public Type Type { get { return typeof(Machine); } }

}
`

  1. In my MachineNode Create method, I have this line:
    node.CreateOutput("Machine", "Machine");

  2. I get this error:
    capture

Maybe I'm misunderstanding this completely, but is it possible to do what I'm trying to do? Thanks ahead for the help!

Save File Inspector

Description: Simple custom inspector when selecting a save file. Just displaying some informations, button to open it, etc.

State: None.

Lots of NullReferenceException in Unity 5.2.0f3 (doesn't work)

(Reverting 36ca904 helps)

When trying to open Window -> Node Editor:

NullReferenceException: Object reference not set to an instance of an object
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-runtime-and-classlibs/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-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
GUIScaleUtility.get_getTopRect () (at Assets/Plugins/Node_Editor/Framework/GUIScaleUtility.cs:16)
GUIScaleUtility.BeginNoClip () (at Assets/Plugins/Node_Editor/Framework/GUIScaleUtility.cs:157)
GUIScaleUtility.BeginScale (UnityEngine.Rect& rect, Vector2 zoomPivot, Single zoom, Boolean adjustGUILayout) (at Assets/Plugins/Node_Editor/Framework/GUIScaleUtility.cs:85)
NodeEditorFramework.NodeEditor.DrawSubCanvas (NodeEditorFramework.NodeCanvas nodeCanvas, NodeEditorFramework.NodeEditorState editorState) (at Assets/Plugins/Node_Editor/Framework/NodeEditor.cs:140)
NodeEditorFramework.NodeEditor.DrawCanvas (NodeEditorFramework.NodeCanvas nodeCanvas, NodeEditorFramework.NodeEditorState editorState) (at Assets/Plugins/Node_Editor/Framework/NodeEditor.cs:86)
NodeEditorFramework.NodeEditorWindow.OnGUI () (at Assets/Editor/Node_Editor/NodeEditorWindow.cs:78)
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-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Nested Scaling Support

Description: Nested Scaling Support will enable for Group Nodes, or generally seen nested canvases.

Progress: Problem: Nested Scale areas get shifted when atleast two groups in the hierarchy are scaled (the scale gets stacked), but the shift amount is yet unknown.
State: Environment to test this out is already setup. Factor for this shift value is definitely the position of the nested group relative to the topmost group, that means each parent group aswell as it's own position influences the shift value. Scale values of each parent group obviously influence the value, too.
Goal: Calculating the shift value with a formula

Location: GUIScaleUtility.cs

Dynamic Node Rect Size

Description: Node Rect size adapting to the content

State: None. Either achievable using reflection, checking the GUIStack size after the node has been drawn for the next time, or by requesting an override function. Way easier if the actualy content is moved from the node body to the side window and only the Inputs/Outputs are drawn (very easy to adjust node body)

Multiple Connection on node input

Hi!
First of all, nice work, this really helps a lot!
So the question/possible feature:
Is it possible to create a connection type that can be connected multiple times with only one input?
like:
A connected to C,
B connected to C

Node Areas / Groups

Description: Ability to group nodes in an area (maybe just colored rect with a header). Nodes that are inside this area are automatically attached, This group can be picked and moved around, together with the nodes, and also resized. Using a button in the header, title and color can be edited. If deleted, the nodes inside are untouched.

State: Petty much done, resizing is supported, color and title can be edited, dragging groups moves also all pinned nodes and subgroups (recursively). All stuff around it is also pretty stable (input, saving, etc.)

References from Substance Designer:
image
image

Undo Support

Description: Undo support is a MUST. Using the default system, this would be absolutely tedious though. A command based pattern would be preferred. Maybe a mix of both is the best choice.

Progress: I've a WIP Command-Pattern Undo Integration (yes, integration into the default system:D ) we can use for the editor when it's finished (Progressing good, but currently on hold). For Runtime, VFW would probably be the best choice as the undo system (also command-pattern). Currently, theres no undo support though.

Memory leak when opening a canvas

Loading a file in the editor and moving the canvas around will result in a large increase of memory usage over time, where only a fraction of it is GC'ed. Unity must be restarted to clear the used memory.

Loading a file in the runtime editor will have the same effect.

This doesn't happen (at least as badly) when there aren't nodes in the canvas.

Making the Node Editor Framework more modular and flexible

As we make the Node Editor Framework more general and add features like groups that not everyone might need, it also get's more complex and filled with potential useless features, depending on the needs.

I've the rough idea of modular system, that will make a lot of features modular and removable. Examples are the grouping, an additional XML save format (future) #43, the (currently default) forward calculation system, the statemachine behaviour (in developement) #34, or additional general nodes like the action-, expression- and conversion nodes (Branch)

That modular system would not be a part of the software code itself, but a general concept of using pre-processor options to integrate these modules.
Partial classes could be the main key to this. Each module could then add variables and functionality to the Node Editor without messing with the standard code.
Unfortunately, adding functionality to existing functions would not be possible.
Most of this is only theory so far, but it may help with the complexity and amount of features that are planned/implemented.

Development branches / Better code versioning

Right now the master (and only) branch contains features that are incomplete, might change and/or contain lots of bugs that might break some stuff (I didn't test it, just a supposition).

It's difficult for a user to see the giant "Major WIP Update" commit and decide if he can update its current version of the code or not.

There should be finer control of what code is in development and what is ready to be released (i.e. using additional branches/tags and correct version control numbering).

Possible references:
https://www.atlassian.com/git/tutorials/comparing-workflows/ (Git Flow works out-of-the-box with SourceTree)

Error occurs when I stop the Unity playmode.

When I open the NodeEditor, and change the Unity playmode to stopped state,
error occurs that Knob texture can not be loaded.
In the source code,
In EditorApplication.playmodeStateChanged, Node Editor trying to LoadCache at the timing to stop the application, but seemed to have failed in an attempt to load the Knob texture in UnityEditor.AssetDatabase.LoadAssetAtPath.

Android Build

When I try to build for android, these two error happens:

Assets/Plugins/Node_Editor/Framework/NodeEditor.cs(891,54): error CS0234: The type or namespace name LoadAll' does not exist in the namespace NodeEditorFramework.Resources'. Are you missing an assembly reference?

Assets/Plugins/Node_Editor/Framework/NodeEditor.cs(946,29): error CS0165: Use of unassigned local variable objects'`

also tried with blank project and the same error happens.

Canvas file reference lost when Loading/Saving

Hi,

Whenever Loading / Saving a canvas, there is that backup mechanic which create the LastSession.asset. This asset creation leads to losing the reference to the original asset for the currently edited canvas. Although its not a problem when saving. It displays the wrong information inside the Editor

image

Might be confusing for the end-user when editing multiple canvas.

Best Regards

NodeCanvas destroyed after returning from Play Mode

Unity version: 5.1.2p3

If I open the Node Editor, enter the Play mode, stop the Play mode and click on the Node Editor window again it stops responding and I get a lot of repeated errors in the console with the following error:

MissingReferenceException: The object of type 'NodeCanvas' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
NodeEditorFramework.NodeEditorWindow.DrawSideWindow () (at Assets/Editor/Node_Editor/NodeEditorWindow.cs:111)
NodeEditorFramework.NodeEditorWindow.OnGUI () (at Assets/Editor/Node_Editor/NodeEditorWindow.cs:104)
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-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Node Editor in Android

Hi everyone :)

I am trying to build a Android application with Node Editor features to perform basic logical application (e.g. if / else)

However since Smartphone only allows pressing operation, I am trying to figure out how to add node (e.g. AllRoundNode) by pressing a button on SideGui() as demonstrated in RunTimeNodeEditor.

Could anyone please guide me a way to achieve such operation? I am a bit lost after reading the "ContextCallback" function ....

Action Node

Description: A generic node for calling actions, both static and instance. The Inputs and Outputs should adapt automatically.

Progress: Currently put on hold because we are unable to just serialize a function. I'm adressing this with a UnityFunc, which is serializeable and also needed for the StateMachine. Kamigaku on the forums has a specialised version already running afaik:)

Location: Due to the dependecny on UnityFunc, mostlyUnityFunc.cs and UnityFuncEditor.cs

WIP Branch

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.