Executing a Script in the Editor When Placing a Game Object

I am trying to improve painting down trees by putting a script in the tree prefab to randomly rotate it when created. (As well as sink it down a little so that trees on slopes don’t ‘float’ any more.)

This works just fine in “Start” but the end result is that all the trees look a little different each time I run the game. So I had the idea of trying it in Excecute in Editor mode so that the tree only calls the script the first time its created and then never again. But this doesn’t work in Start() inside the Editor. I have tried a number of other ideas, but none of them seem to work. Is what I’m trying to do possible? And how would you do it?

There are ways you could do this by calling Start in combination with ExecuteInEditMode and e.g., set some serialized flag the first time the rotation is applied, but really I think the better option would be to apply your rotation at the time the tree is spawned from your tool (assuming you own the code to whatever tree placement tool you’re using).