- Home /
How to Massplace Assets with Script at Edittime
Hi all
For my current Prototype I'd like to write a small utility script to massplace arbitrary Assets based on some rules.
The Unity built in trees or detail meshes don't do the trick for me as I want to use the new unity trees from the tree creator (which, to my knowledge, still don't work with the terrain script trees, as the animation is lost and other things with it), and I'd like to include colliders on some of the assets.
So is there any possibility to instantiate a prefab from a script at edittime? Is done just like what I would do to instantiate something at runtime, just from an editor script?
Answer by Jessy · Feb 11, 2011 at 05:10 PM
It sounds like you already know what needs to be done; the short answer to each of your questions is yes. You just need to trigger execution of the code somehow; here are a couple tools available to you:
http://unity3d.com/support/documentation/ScriptReference/MenuItem.html
http://unity3d.com/support/documentation/ScriptReference/ContextMenu.html
http://unity3d.com/support/documentation/ScriptReference/CustomEditor.CustomEditor.html (Try a GUI.Button with that.)
Here's something you can use to preserve prefab links, if you're interested. http://unity3d.com/support/documentation/ScriptReference/EditorUtility.InstantiatePrefab.html
Okay, then I just need to try what I had in $$anonymous$$d :).... thanks for the answer, and the useful links.