Hi all,
I have a prefab object, that I’d like to populate my world with, say 200-300 of them, laid out in a completely parametric procedural way (e.g. in a grid, or circle, spiral, surface of a sphere etc).
I know how to do this in play-mode using a prefab and creating all the instances in a Start() function. But I’d like to be able to see this layout in the editor too, so I can manually position a number of helper objects, cameras etc depending on how the layout looks. I feel like what I want to do is run a script to populate the hierarchy and do the layout with all of the instances, while not in play-mode but in edit mode. And all of those instances are permanently placed in the scene file (and thus saved with it). But then if I don’t like the layout, I want to have them all deleted, tweak a few of the layout parameters, and then re-run the script and have a new layout generated. Then once I’m happy with that layout, I can manually position my cameras etc in the editor.
In 3D software like Maya / Houdini etc this would be quite easy just writing some python in the console, or even create a custom python tool and sticking it on the toolbar or something.
It would be even more amazing, if - instead of having to delete all of the instances, tweaking the layout parameters, and re-running the layout generation script - I could have the layout parameters affecting the layout in real-time, but still in edit-mode instead of play-mode. I.e. in edit mode I have 100 of my instances all placed in the right position and in my hierarchy etc. then I change the layout parameters in my script from 10x10 grid to 10x15 grid and immediately the layout changes. Or I tweak the grid distance and the layout updates immediately. (This is just luxury, I’m happy to press an ‘update’ button if need be ![]()
Is anything like this possible in Unity using C# scripting? Or would I need to write a proper C++ plugin?