- Home /
Apply texture on prefab
Hello I have a script where I clone a certain prefab, which is a sphere by the way, several times. I 'd like to apply on each clone a texture, which is a PNG image inside the folder /Assets/Resources ("/Assets/" is the root of the project). I have several PNG images and I'd like to choose each one of them randomly and I have no Idea on how to do this. The documentation of unity didn't help me at all. Thank you
Comment
Try creating an array of the different textures using var 1 : Texture; var 2 : Texture; var picarray : array; , and see where that takes you.
Answer by Justin Warner · May 14, 2012 at 10:58 PM
As tw1st3d said, do the array of textures.
Then you can use Random to actually get a random texture. Apply via something like this.