x


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.

more ▼

asked Apr 21 '11 at 02:23 AM

Alex 9 gravatar image

Alex 9
79 19 18 20

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first
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];
}
more ▼

answered Apr 21 '11 at 04:01 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

great script, Eric5h5. I must say, your the best coder I "Know"

Apr 21 '11 at 03:54 PM zmar0519
(comments are locked)
10|3000 characters needed characters left

i have attached this script to the gameobject which i wish to change texture but nothing is happening. any ideas why?

more ▼

answered Nov 10 '11 at 04:07 PM

mehowe7 gravatar image

mehowe7
31 15 15 17

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.

Sep 19 '12 at 02:25 PM BFDesign
(comments are locked)
10|3000 characters needed characters left

This Script works parfectly.

more ▼

answered Jan 29 at 09:52 PM

Cmujica gravatar image

Cmujica
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2188
x1089
x570
x179
x36

asked: Apr 21 '11 at 02:23 AM

Seen: 1359 times

Last Updated: Apr 24 at 02:52 AM