Hi,
I’ve been trying to step through a define array size, but for some reason everytime I destroy an object in the array, it’s resetting my variable back to zero. Here’s the code
function OnMouseDown(){
if(PlayerCCC < GlobalVariables.ColourChangeSel.Length){
Debug.Log("PLAYERCCC = " + PlayerCCC + " < CCS.Length = " + GlobalVariables.ColourChangeSel.Length);
if(GlobalVariables.ColourChangeSel[PlayerCCC] != null){
gameObject.renderer.material.SetColor("_Color", GlobalVariables.ColourChangeSel[PlayerCCC].renderer.material.color);
Destroy(GlobalVariables.ColourChangeSel[PlayerCCC]);
PlayerCCC += 1;
Debug.Log("NOT NULL. PLAYER CCC = " + PlayerCCC);
}
}
}
Can anyone tell me why this is happening or offer a solution? I’ve tried searching the internet and re-read the unity Script Referencing.
Thanks