Hi guys!
(You can skip this part)
After a few months of as2, then c#, then as3, i found out i didn’t get quite where i wanted with my game. Being a fan of Minecraft i thought i would just start a similar project in unity. The only thing i dont like about it this far is that i have to draw the levels myself ( in as3 i just generated them with code ). I tried to fix this by having a simple mesh just to hold my script ( a cube that is ).
This script makes unity stop responding if i run it in its window, and does the same if i build it first aswell.
for (var z = 0; z < 100; z++) {
for (var y = 0; y < 10; y++) {
for (var x = 0; x < 100; x++) {
var cube = new GameObject.CreatePrimitive(PrimitiveType.Cube);
//cube.AddComponent(BoxCollider);
var i = Random.Range(0.0,3.0);
if(i < 1 && i > 0){
cube.renderer.material.color = Color.red;
}
if(i < 2 && i > 1){
cube.renderer.material.color = Color.blue;
}
if(i < 3 && i > 2){
cube.renderer.material.color = Color.green;
}
Instantiate (cube, Vector3(x, y, z), Quaternion.identity);
}
}
}
}
Yes, i do realize I’m trying to generate 100,000 blocks ![]()
Anyway, how would i make unity do this without stopping to respond? is there any way i can make it load one after the other without freezing up?