-
Notifications
You must be signed in to change notification settings - Fork 414
Loading canvas based on Selection.activeTransform? #202
Comments
NodeEditor window uses NodeEditorUserCache to store the currently open instance, so you'd have to access that. So, if these canvases live in the scene, it could work nicely. Set useCache to false and call SetCanvas, and the window should switch to editing it next time it redraws (which will set the curNodeCanvas, that is really only for the time frame when it is drawn, e.g. multiple windows can draw one after another, setting their canvas as current while drawing.). If your canvases are assets (so not instances), you do not want to edit them directly, that might at best result in inconsistent files, and at worst break completely due to how ScriptableObjects are handled. Generally when you load a canvas from assets, it copies it into an instance in memory to prevent weirdness from unity. |
My canvases do live in the scene so it should be a simple solution. I'm a little confused how to set useCache to false when it is a private field, I've tried setting the 'CACHE' custom directive in the player settings, but I am still getting a exception: |
My bad, didn't notice that. Been a while since I wrote that code. |
Coming back to this issue, I've found that userCache.LoadNodeCanvas is the method I was looking for. I've included my script which will find the corresponding node canvas attached to my gameobject and set the displayed node canvas to that. Note that it's specific to my project, so a lot of it is unnecessary, but it's enough to understand I think. Here is a pastebin link if the formatting is bad: https://pastebin.com/F1i8T1Z3
|
I want to extend the Editor functionality such that if I have a manager on a gameobject that contains a specific canvas (or instance of a canvas), then if I click on the gameobject, the Node Editor window should update and load it so you can see the nodes activating in real-time.
In my Manager class, I added these functions:
where SetupTree is being called every .2 seconds within a coroutine, and behaviorTree is the canvas given to the Manager component of my game object. Also, I commented out the
NodeEditor.checkInit(true);
line because it was throwing an exception since I can't call a GUI function from outside the GUI loop.Nothing is happening here, should I extend the NodeEditor instead?
Originally posted by @Seneral in #124 (comment)
The text was updated successfully, but these errors were encountered: