简体   繁体   English

当我调整视图时,统一场景和游戏视图中的对象正在消失

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

So I'm trying to learn Unity DOTS and I've built out a program that renders a bunch of cubes.所以我正在尝试学习 Unity DOTS 并且我已经构建了一个渲染一堆立方体的程序。 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显示剪辑的屏幕截图

RenderBounds值保留为default(AABB)RenderBounds发生这种情况,因为它的大小/范围为 0,因此使您的网格只是平截头体剔除系统的一个点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM