所以我正在尝试学习 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
});
}