Hello everyone. This is my first post here. Just started ,recently, with Godot (just a couple of days ago) and, since I work with 3D for over 30 years and I program in a few programming/scripting languages, I'm loving what I found out until now, in Godot. I came across an issue, though. I created a MeshInstance node and added new ArrayMesh and a script to it. The script creates all the necessary arrays (Vertex, Normal, Index... still missing the UVs) and the object gets created fine. But... It only gets created when I open the project. If I make adjustments to the code, I get no feedback of the changes in the Editor. I have to run the project or save it, close it and open it again. I did add the tool keyword to the top of the script, to try to make it update it in the editor. I even have some "exposed" variables (using the uniform prefix) and they do show up in the Inspector. But, even if I change them, the mesh doesn't update. Probably it is due to the fact that I'm generating the code in the _ready function and that only executes at the start of the execution of the project. So, what other func should I use to make sure that any changes to the code (or the uniform variables) trigger a new calculation of the mesh? Thank you very much in advance and forgive any mistakes I may have written, as english is not my native language.
Procedural Mesh
From some experimentation I've just done, some notes: - ready isn't called by tools when code changes and is saved. But init is. - changes to inspector variables won't be detected unless you are checking them in _process, or have them set up to call a function on set.
Have a look at https://docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html It shows how to have an inspector value that changes behavior in a tool.
So overall, I'd say try this: - Make a function that generates the mesh. - Call this function from _init(), that will let it regenerate on code changes. - Add the export setget stuff (from that link above) for each property you want in the inspector. - Also call the generate function from these setget functions, so the mesh regenerates when inspector changes happen.
At least that's how it seems to work, I haven't actually tried mesh changes in a tool, just simple stuff.
@Kojack said: From some experimentation I've just done, some notes: - ready isn't called by tools when code changes and is saved. But init is. - changes to inspector variables won't be detected unless you are checking them in _process, or have them set up to call a function on set.
Have a look at https://docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html It shows how to have an inspector value that changes behavior in a tool.
So overall, I'd say try this: - Make a function that generates the mesh. - Call this function from _init(), that will let it regenerate on code changes. - Add the export setget stuff (from that link above) for each property you want in the inspector. - Also call the generate function from these setget functions, so the mesh regenerates when inspector changes happen.
At least that's how it seems to work, I haven't actually tried mesh changes in a tool, just simple stuff.
It worked GREAT!!! Thank you so much, Kojack. I'm loving this stuff.
- Edited
you can make your generator a editor plugin implementing a new custom node type and then you'll be able to get visual feedback in the editor too(when changing exposed properties via inspector for an example). It's been a while but I've done so myself.
Hello everyone. This is my first post here. Just started ,recently, with Godot (just a couple of days ago) and, since I work with 3D for over 30 years and I program in a few programming/scripting languages, I'm loving what I found out until now, in Godot. I came across an issue, though. I created a MeshInstance node and added new ArrayMesh and a script to it. The script creates all the necessary arrays (Vertex, Normal, Index... still missing the UVs) and the object gets created fine. But... It only gets created when I open the project. If I make adjustments to the code, I get no feedback of the changes in the Editor. I have to run the project or save it, close it and open it again. I did add the tool keyword to the top of the script, to try to make it update it in the editor. I even have some "exposed" variables (using the uniform prefix) and they do show up in the Inspector. But, even if I change them, the mesh doesn't update. Probably it is due to the fact that I'm generating the code in the _ready function and that only executes at the start of the execution of the project. So, what other func should I use to make sure that any changes to the code (or the uniform variables) trigger a new calculation of the mesh? Thank you very much in advance and forgive any mistakes I may have written, as english is not my native language.
Thank you very much, but that is probably a bit too advanced for a Godot newby. But I got it working making the code be called from the init func instead of ready, and adding setget funcs to my code.