in my platform game there is a original platform called “platform1”. this platform will be destroyed after short time. the following four platforms are clones with the name “platform1(Clone)”. They are taged with the tag “Ground”.
i want to change the textures of every of this four clone platforms.
for this i use:
var tex3 : Texture2D = Resources.Load("platform1_tex2");
platforms.renderer.material.mainTexture = tex3;
when i use this it changes just the texture of one of this four platforms:
var platforms : GameObject;
platforms = GameObject.Find("platform1(Clone)");
when i use this i got this error: The object of type ‘GameObject’ has been destroyed but you are still trying to access it.
var platforms : GameObject;
platforms = GameObject.FindWithTag("Ground");
This is not a good way to go about this. If you are changing every one of the platforms’ textures, colors, or whatever then the platforms should all use one material and then you can change that shared material. If you’ve already committed to using that material on many things, then you will have to find each of the objects using a FindGameObjectsWithTag or another Find type command which returns multiple objects, then iterate through the returned array and update each one of the objects materials (which will copy the material and each will have their own unique copy).
Or course it isn’t, because renderer is part of a gameObject, not part of a gameObject[ ] (an array of gameObjects). You’ll have to modify each one by iterating through that array.