Hi, Is there a way of setting a texture to an object on the fly?. I have a set of textures in my project and I want to put them in a little ball according to a previous result. Thanks in advance
Sure... Code (csharp): var myTexture1 : Texture2D; var myTexture2 : Texture2D; function Update() { if (Input.GetButton("Fire1")) { renderer.material.mainTexture = myTexture1; } else { renderer.material.mainTexture = myTexture2; } } Something like that.... --Eric
The problem is that my input is an integer number from 1 to 90 and the textures have their names in the form "name01"..."name90". So I want to know if is possible to assign the textures without having to put them previously in the inspector. Thanks
You could do Code (csharp): var myTexture : Texture2D[]; var number = 42; function Update() { renderer.material.mainTexture = myTexture[number]; } But with 90 textures, that's a lot of draggin' and droppin'. Have a look at Resources.Load. --Eric