-
Notifications
You must be signed in to change notification settings - Fork 413
Is it possible to include functionality inside of NodeEditorSaveManager to create new canvas? #87
Comments
Sorry for the late reply. Wasn't able to set up email notifications on my (new) phone yet so I have to learn to manually check emails lol NodeCanvas canvas = ScriptableObject.CreateInstance<NodeCanvas> ();
// Populate canvas with some nodes and stuff
NodeCanvasSaveManager.SaveNodeCanvas ("Assets/CreatedCanvas.asset", canvas, false); It's pseudocode but it should work. Let me know if you encountered any errors of if I misunderstood you:) |
No worries and thanks! I should have probably elaborated more haha. I want my Duplicate (new canvas) button to:
So the main obstacle is loading the created canvas into the node editor window. Here's what I have so far:
This works at emulating clicking "new canvas" but only once. I'm assuming some caching prevents it from working again since clearing that allows me to do it again. If I attempted to create the node right after these lines of code, I get a NodeEditor.curNodeCanvas is null error. I tried delaying the call, but the canvas appears to stay null for some reason. |
Use I do have a new update in development which emphasizes this, it is basically a wrapper for holding canvases, called a user. More about it once I commit it:) |
There's no way to access that script from a node, though right? Since it's not an editor script? If not, I'll just add my button else where. :) If I do use say the NodeEditorWindow to add my code, how do I get my node? For example, usually to get the gameobject being displayed by the inspector, you use Selected.activeGameObject. How would I get the active node? I'm pretty new to scriptable objects tbh haha - sorry for my noobness lol. |
You can try to put your script in an editor folder. Obviously it then won't be able to be used at runtime... |
Cool that you've found a solution:) |
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?
The text was updated successfully, but these errors were encountered: