- Home /
Changing an Object tag by changing texture
hello, i am trying to set a "street light" to act as a collider. i found this script on the docs:
var textures : Texture[] ;
var changeInterval : float = 0.33;
function Update() {
if( textures.length == 0 ) // nothing if no textures
return;
// we want this texture index now
var index : int = Time.time / changeInterval;
// take a modulo with size so that animation repeats
index = index % textures.length;
// assign it
renderer.material.mainTexture = textures[index];
}
this changsmy materiel great - I have 3 material named : red orange green
but now i want to change the object "tag", so every time it is using the red material it will set the "tag" to "stop" and while it is green or orange the "tag" will be "go"
any ideas in (not in C please) will help a lot
Answer by werneroi · Nov 26, 2011 at 10:35 PM
But now i solved it!!!! what i did is set the object's material to 0. that got rid of the material and then when i tried printing the textures var value it worked by adding:
print (textures[2]);
i dont know yet how to print the current result of the array, but at least i can check once a value is true for what i need is good enough. thanks again.
Sorry I went to sleep otherwise i would have answered. Glad you figured it out :)
Answer by werneroi · Nov 26, 2011 at 10:35 PM
First of all thank you for help. however... i tried adding this and nothing happend. so i try just to print the [index] by doing so:
print (this.gameObject.renderer.material.GetTexture("_MainTex"));
and it only shows me the first texture and nothing is changing there :(
Answer by werneroi · Nov 26, 2011 at 10:35 PM
Ooppps, doest actually what i need. So, How do I print out the value of the var index?