I have searched for this for a long time now, but I haven’t been able to find an definitive answer. I want to be able to customize an object from the editor view. I don’t want to set up variables like max velocity, I want to be able to change it.
For instance, I have a spike trap, which consists of a 2d boxcollider and a few single spikes images. What I’d like to do is to have a slider to set the number of spikes, and the trap would dynamically grow or get smaller by adding or removing spike images and changing the collider’s size.
So, how do I make some kind of listener that will trigger an action in the Editor Mode?
I can’t actually tell you how to increase the number of spikes, as this depends on how things are setup in your project but it’s perfectly possible use use the extended editors to add / remove game objects from the scene, to create / edit meshes etc.
Firstly, you want to create a prefab of the spike trap, by dragging the object from the scene into the project folder. There, if you select the object, you can make changes to it and it’s children only one layer down, unfortunately you can’t make changes to the children of this objects children, but I don’t think that will be necessary for a simple spike trap.
Once you have made the changes to the prefab in your project folder, it is important to press the “Apply” button at the top right of the inspector.