- Home /
Cycle Textures Over Time
I know that this might be a commonly asked question but i could not find an answer. How can i make an array of textures and make a gameobject cycle through those textures over time. Any help would be nice.
Answer by Eric5h5 · Apr 21, 2011 at 04:01 AM
var textures : Texture2D[]; var delay = 1.0; private var textureCounter = 0;
function Start () { InvokeRepeating("CycleTextures", delay, delay); }
function CycleTextures () { textureCounter = ++textureCounter % textures.length; renderer.material.mainTexture = textures[textureCounter]; }
great script, Eric5h5. I must say, your the best coder I "$$anonymous$$now"
Answer by mehowe7 · Nov 10, 2011 at 04:07 PM
i have attached this script to the gameobject which i wish to change texture but nothing is happening. any ideas why?
Tested it and it works fine. Created empty scene, added a sphere, added a directional light, added script to sphere, set number of textures to 4, filled the texture2d slots with 4 different textures, left delay at 1, hit play, watched the textures change.
Your answer
Follow this Question
Related Questions
weapon bobbing 1 Answer
How Can I enable and then disable a light in unity after a certain time? 1 Answer
How to make an enemy respawn? 0 Answers
Autodetect new assets on Mac takes a minute 0 Answers
Rotating texture around sphere 2 Answers