Hi
My unity3d crashes when I create really alot of cubes with c#
var cubed = GameObject.CreatePrimitive(PrimitiveType.Cube);
I think I made about 500 of these different sizes but it crashes.
Any ideas what todo?
Hi
My unity3d crashes when I create really alot of cubes with c#
var cubed = GameObject.CreatePrimitive(PrimitiveType.Cube);
I think I made about 500 of these different sizes but it crashes.
Any ideas what todo?
Do you have a special script attached to this cube ?
no Im just putting cubes next to each other but I decrease size gradually. Is there some limit here?
sorry I had this in there
foreach(GameObject gameObj in GameObject.FindGameObjectsWithTag(“Cubes”)){
when I create a cube.
But why would that crash the whole program?
foreach(GameObject gameObj in GameObject.FindGameObjectsWithTag("Cubes")){
This is called in every cube ?
I fixed it and took that out. But that was only in on creation of one cube. So why would foreach crash on 500?
It was a foreach to change the material of an object.
If you have 500, and you iterate over all of them once for each, that is 250000 objects to find and iterate over. Depending on what you did to them it might not crash but would probably take a while.
Well, hopefully it isn’t in Update()…