- Home /
Editor Scripting - Override Scaling
I have a script to create a cube procedurally (it'll be more sophisticated than a cube eventually!). I have added this to the editor menu - all this works well. What I need to do now is to adjust the mesh when scaling - either by overriding the scaling gizmo or by creating a new gizmo type. Any suggestions on the easiest way to do this?
(To give some context, I want to procedurally create a very simple house. As it's scaled along x or z I want to insert more windows. As it's scaled on y, I want to add more floors.)
Thanks.
Answer by Jesse Anders · Feb 19, 2011 at 10:25 AM
I'm not really sure what the best way to do that would be, but what comes to mind is, on a per-update basis, compute the number of windows, floors, etc. based on the current scale, and then rebuild the mesh if and only with those values have changed with respect to the previous update.
(There might be some way to interact with the gizmo in a more direct way, but if so I don't know it off the top of my head.)
[Edit: That doesn't really address all the possible issues involved though, since you'd probably want more control over the behavior than that (e.g. house size changes as scale is changed, but windows, doors, floors, etc. all maintain the same relative size and are simply added and removed as needed). Maybe a better solution would be to create your own scene-view interface using picking and so on.]
Your answer
Follow this Question
Related Questions
Unity Editor Scripts: GameObject Added / Removed Event? 1 Answer
How can I preserve static object/data between editor and play? 2 Answers
HideFlags on children of visible objects. 3 Answers
How to record the entire game and user behaviour for a research project? 1 Answer
Assign Color[] var in prefabs using Editor Scripting 1 Answer