Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

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.