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



所以我正在尝试学习Unity DOTS,我已经构建了一个程序来渲染一堆立方体。但出于某种原因,在游戏视图和场景视图中,当我移动相机时,屏幕边缘的立方体开始消失。我不知道是否有某种设置导致不可见的对象无法渲染或其他什么,或者可能与它们是实体有关?

这是我用来生成瓦片的代码:

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
});
}

显示剪切的屏幕截图

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

最新更新