//render mesh, update mesh private void RenderAndUpdateChunksOnMainThread() { MaterialPropertyBlock solidProperty = MaterialProperties.GetSolidPropertyBlock(); MaterialPropertyBlock liquidProperty = MaterialProperties.GetLiquidPropertyBlock(); bool flag = true; lock (m_ChunksToRender) { HashSet <Vector2Int> .Enumerator iterator = m_ChunksToRender.GetEnumerator(); while (iterator.MoveNext()) { Vector2Int chunkPos = iterator.Current; if (!m_Chunks.TryGetValue(chunkPos, out Chunk chunk)) // 未加载完成 { continue; } if (chunk.ShouldUpdateMesh && !chunk.IsBuildingMesh) { chunk.TryBuildingMeshAsync(); } flag &= !chunk.IsBuildingMesh; chunk.RenderChunk(m_SharedSolidMaterial, m_SharedLiquidMaterial, m_MainCamera, solidProperty, liquidProperty); } iterator.Dispose(); } if (m_IsStartUp && flag && m_Chunks.Count > 0 && m_ChunksToLoad.Count == 0) { m_IsStartUp = false; OnChunksReadyWhenStartingUp?.Invoke(); } }