Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to automacicaly random rotate pefab during placement in editor in unity 4.5.3?

I can make it autorotate in game(at start) but I want it to be visible in editor and at fixed rotation after placement.

share|improve this question
up vote 5 down vote accepted

Found it! Attribute [ExecuteInEditMode] does what I want

public class RandomRotation : MonoBehaviour {
    void Start () {
        this.transform.Rotate(0, MyRandom.Rotate(this.GetInstanceID()), 0);
        this.transform.localScale = MyRandom.Scale (this.GetInstanceID(), 0.4f, 1f);

share|improve this answer
isn't editor scripting in unity pretty cool – jhocking Aug 15 '14 at 13:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.