How runtime get all 10 Sphere(Clone) name GameObjects

Hi developres!
I have some problems, when I runnig my project it created 10 sphere, all names are “Sphere(Clone)”, I am finding with this code only one sphere!

*var points = GameObject.Find( “Sphere(Clone)” );

print( points.transform.position );

points.renderer.material.color = Color.red; // red for see what sphere I finding*

I want to get all 10 spheres, but they have same name, Help me please if you have idea

If you use [tags][1] rather than a name, [GameObject.FindGameObjectsWithTag][2] will return an array of all gameObjects with the defined tag. Personally I would go with the answer by flaviusxvii, store all your spheres in a list after you have instantiated them. (upvoted) [1]: http://docs.unity3d.com/Documentation/ScriptReference/GameObject-tag.html [2]: http://docs.unity3d.com/Documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html

2 Answers

2

When I need to find them later, I put Instantiated objects in some kind of List for later reference.

Thanks I solve this problem another way !