Spawning random small cubes in a big invisible cube using Unity C#
Why does SpawnSmallCubes() generate only a single cube?
if(cube.GetComponent&lt;Renderer&gt;().material.color.a &lt;= 0) this line is unecessary
GetComponent() calls can be reduced by holding onto the Renderer instance, assuming you aren't swapping it out
smallCubes.ToArray() conversion is unecessary
FadeOutCube() also spawns the cubes. This isn't obvious from the naming