Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to rotate all my GameObjects by 90 degrees. To do that I need to select all my GameObjects, how can I do so?

share|improve this question
Do you mean you want to do this in code, or in the editor? –  user744 May 2 '11 at 13:49

1 Answer 1

up vote 3 down vote accepted

To loop over all GameObjects, use the following code:


for(var gameObj : GameObject in GameObject.FindObjectsOfType(GameObject))
    // modify gameObj.transform.rotation


foreach(GameObject gameObj in GameObject.FindObjectsOfType<GameObject>())
    // modify gameObj.transform.rotation

Also see the manual for FindObjectsOfType.

share|improve this answer
FindObjectsOfType doesn't have a generic version, as far as I can tell. So you have to do FindObjectsOfType( typeof( GameObject ) ) as GameObject[]. –  Tetrad May 2 '11 at 16:54
Good to know; I'm not at a computer with Unity to test it. –  Ricket May 2 '11 at 17:45

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.