Unity spawns many objects at runtime

I created a simple project where approx. 7000 cubes were created in the scene (with a VR camera), but the problem is that when I move the camera to see all the cubes, the FPS becomes very bad, something like 5-6 frames. My i7 PC is with a GTX 1070, and I thought that he needed to collect hundreds of thousands of cubes without any problems. Indeed, I saw minecraft, it seems there is no problem to draw cubes))

So the question is, is it possible to optimize the scene so that all the cubes draw a single call or something to ensure good performance?

In fact, I made all the cubes static and there are no textures in the standard material only ...

Here's what it looks like now: enter image description here

Directional Light , - .

:

private void AddCube(Vector3 coords)
{
    var particle = (Transform)MonoBehaviour.Instantiate(prototype.transform, holder.transform);

    SetScale(particle);
    SetPosition(particle, coords);

    cubes.Add(particle.gameObject);
    particle.gameObject.isStatic = true;

}

private void SetScale(Transform particle)
{
    particle.localScale = new Vector3(Scale, Scale, Scale);
}

private void SetPosition(Transform particle, Vector3 coords)
{
    particle.position = coords;
}

Stats: Stats screenshot 41 fps, , . , , FPS , .

+6
1

, , , . , StaticBatchingUtility, .

.

StaticBatchingUtility.Combine(GameObject cubesRoot);
+5

Source: https://habr.com/ru/post/1014990/


All Articles