To access an object’s main texture you go through the renderer’s material.
for (var i = 0; i<x.Length; i++) {
y _= x*.renderer.material.mainTexture;*_
} You can also go by the property name in the shader by using the [GetTexture-function][1]: var tex : Texture = renderer.material.GetTexture (“_BumpMap”); Remember that the array y doesn’t have to be public, you could make it static or private (depending on your need for access level) and resize it before you iterate through the x array. y = new Texture[x.Length];
_*[1]: http://docs.unity3d.com/Documentation/ScriptReference/Material.GetTexture.html*_