I have a list of instantiated prefabs. A function is called that loops through them and for each gameobject that is not set to owner==1, its renderer is disabled. This part WORKS. The part that does not work is when I call the function that loops back through them and re-enables the renderer using almost the exact same code, just changing false to true for the renderer setting.
Here is the loop that functions properly:
for (var i = 0; i+1 <= landtiles.Count; i++){
var x : Transform;
x = landtiles[i];
if (!(x.GetComponent(tilescript).owner == 1)){
x.renderer.enabled = false;
}
}
Here is the loop that does not:
for (var i = 0; i+1 <= landtiles.Count; i++){
var x : Transform;
x = landtiles[i];
x.renderer.enabled = true;
Debug.Log(x.renderer.enabled);
}
I tried using the exact same code in loop 2 as in loop 1 but just changing false to true, but that did not work. So instead of limiting myself to just those gameobjects with owner == 1 I had it set renderer.enabled to true for each tile in the list. This also did not have any of the gameobjects display in game.
The kicker is Debug.Log(x.renderer.enabled) returns true. Why is this not rendering in game?
↧