Objects in unity scene and game view are disappearing when I adjust my view

1.9k views Asked by At

So I'm trying to learn Unity DOTS and I've built out a program that renders a bunch of cubes. But for some reason, in both the game view and the scene view, when I move the camera around, the cubes just at the edge of the screen start to disappear. I don't know if maybe there's some setting that causes non-visible objects to not be rendered or something or maybe it's something to do with them being entities?

This is the code I'm using to spawn the tiles:

private void SpawnTiles()
{
    EntityArchetype tileArchetype = entityManager.CreateArchetype(
        typeof(Translation),
        typeof(Rotation),
        typeof(RenderMesh),
        typeof(RenderBounds),
        typeof(LocalToWorld),
        typeof(TileComponent)
    );
    for (float i = 0f; i < gridX; i++)
    {
        for (float j = 0f; j < gridY; j++)
        {
            MakeTile(tileArchetype, new float3(i, 0.0f, j));        
        }
    }
}

private void MakeTile(EntityArchetype tileArchetype, float3 translation)
{
    Entity tile = entityManager.CreateEntity(tileArchetype);
    entityManager.AddComponentData(tile, new Translation
    {
        Value = translation
    });

    entityManager.AddComponentData(tile, new TileComponent
    {
        x = (int) translation.x,
        y = (int) translation.y,
        z = (int) translation.z,
        isOccupied = false,
        isTraversable = false,
        index = CalculateIndex((int) translation.x, (int) translation.y, (int) translation.z),
        cameFromTileIndex = -1
    });

    entityManager.AddSharedComponentData(tile, new RenderMesh
    {
        mesh = tileMesh,
        material = tileMaterial
    });
}

Screenshot showing clipping

1

There are 1 answers

0
Andrew Łukasik On

This happen when RenderBounds value is left at default(AABB) as it has 0 size/extent hence making your mesh a mere point for the frustum culling system.