var textur:Texture[];
var mesi:GameObject[];
static var idx:int;
function Update(){
renderer.material.mainTexture=textur[ idx ] ;
attivaMeseCorrente(idx);
}
function attivaMeseCorrente(index : int){
for (var i=0;i<12;i++){
if (i== index){
mesi[idx].SetActiveRecursively(true);
}
else{
mesi[idx] .SetActiveRecursively(false);
}
}
}
I would set active only the object indicated by the VAR idx (it is changed in another script).
With this script will be actived only the object [12] when idx = 12
But if for example idx = 7, object [7] doesn’t active and I don’t know why!
ps: object [12] is actived properly but if idx become 11 or other, object [12]do not turn off
hmm i guess the only possibility is tht idx changes through 0-11 all in one frame!!
so it remains as 11 as per the update of the above script …Did u try Debug.Log(index);
try to change it like the following it ma work… just a guess…
var textur:Texture[];
var mesi:GameObject[];
static var idx:int;
function Update(){
}
function attivaMeseCorrente(index : int){
for (var i=0;i<12;i++){
if (i== index){
mesi[idx].SetActiveRecursively(true);
}
else{
mesi[idx] .SetActiveRecursively(false);
}
}
}
You want to access mesi instead of mesi[idx]. You are not actually looping through all of mesi, but rather setting the same one over and over 12 times.