public void UpdateChunk() { if (hmapRecive) { float playerDstToEdge = Mathf.Sqrt(bounds.SqrDistance(playerPos)); bool visibe = playerDstToEdge <= maxViveDst; bool wasVisible = isVisble(); if (visibe) { int LODIndex = 0; for (int i = 0; i < lodInfo.Length - 1; i++) { if (playerDstToEdge > lodInfo[i].visibleDistance) { LODIndex = i + 1; } else { break; } } if (LODIndex != prevLODindex) { LODMesh lodMesh = lodMeshes[LODIndex]; if (lodMesh.hasMesh) { prevLODindex = LODIndex; meshFilter.mesh = lodMesh.mesh; } else if (!lodMesh.hasRequsetMesh) { lodMesh.RequsetMesh(mapH, meshSettings); } } TerrainChunksVible.Add(this); } if (wasVisible != visibe) { if (visibe) { TerrainChunksVible.Add(this); } else { TerrainChunksVible.Remove(this); } SetVisible(visibe); } } }