- Home /
Question by
Persona · Nov 24, 2012 at 02:15 AM ·
gameobjectarray
Getting the Script component of a GameObject in an Array
How do I get the script of every gameobject in an GameObject[] array? I have it entering a loop after filling the array with objects with the same tag, but I can't tell it to get the script component without a error.
Comment
Best Answer
Answer by Loius · Nov 24, 2012 at 02:49 AM
for ( var go : GameObject in FindObjectsOfType(YourType) ) {
go.GetComponent.<YourType>().YourFunction();
}
Your answer
Follow this Question
Related Questions
Transport unknown amout of objects with GameObject array 0 Answers
View an array of the transform position/rotation of all game objects with a specified tag., 0 Answers
Spawning GameObjects with help of classes --- Attaching classes to GameObjects 1 Answer
New Object Pooling Problem 1 Answer
How to set to game objects's position from 2 different game objects arrays equal to each other? 0 Answers