IEnumerator RenderHexMap() { yield return(new WaitForSeconds(0.01f)); NativeArray <Entity> entities = m_EntityManager.GetAllEntities(); m_ChunkMap = new int[m_TotalCellCount]; for (int i = 0; i < entities.Length; i++) { //取出实体,如果实体不满足条件则跳过 Entity entity = entities[i]; if (m_EntityManager.HasComponent <NewDataTag>(entity)) { continue; } if (!m_EntityManager.HasComponent <ChunkData>(entity)) { continue; } ChunkData chunkData = m_EntityManager.GetComponentData <ChunkData>(entity); HexGrid.AddCellToChunk(chunkData.ChunkId, chunkData.ChunkIndex, chunkData.CellIndex, entity); //Debug.Log(chunkData.CellIndex + "====" + chunkData.ChunkId); m_ChunkMap[chunkData.CellIndex] = chunkData.ChunkId; } entities.Dispose(); }