Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2.01k stars 414 forks source link

Using the Node editor to edit selected monobehavior in scene #178

Closed altschuler closed 5 years ago

altschuler commented 5 years ago

I'd like to use the node editor to edit some data attached to the selected gameobject in a scene, in the same way that the PlayMaker FSM editor is editing the data of the selected FSM in a scene.

That means I don't need the import/export etc, but just want to "translate" the data in the component to something the node editor understands and save it back directly.

Is this use case demonstrated somewhere? I've poked around and saw the scene save functionality, but couldn't figure out exactly if that's what I was looking for.

Any pointer greatly appreciated :)

Thank you for a very nice project!

Seneral commented 5 years ago

You have two options I see right now, change the editor window (or make a new one) so that it is tailored to that use case (you could throw out lot's of code, like the NodeEditorUserCache which is responsible for saving. Or you coud making an own Canvas type (extend NodeCanvas). That way you could use the ScriptableObject's built-in Update function, afaik it should be called when selection changes. Then you could update the canvas contents accordingly. That way you could still save and snapshot but with some extra boilerplate stuff even in the interfac (new canvas of the new type, etc). Editing the window shouldn't be that hard so I'd go with that, but copying and making a new one would be best. Delete some menu entries you don't need, remove NodeEditorUserCache references and handle the canvas and editor state yourself.

altschuler commented 5 years ago

Thank you, I'll try extending the canvas. ScriptableObject's don't receive Update messages afaik, but should be solvable with Selection.selectionChanged or something :)