/// <summary> /// Fully constructs this Tile. This includes creating a Mesh, painting /// the terrain, and adding details (grass, objects, etc.) /// /// By default, calculating heights is done off of the main thread but /// can be disabled. /// </summary> /// <param name="onComplete">Called after all calculations have completed. /// <see cref="onComplete"/>Can be null if the result is not needed.</param> /// <param name="async">Perform mesh computation asynchronously</param> public void Generate(Action onComplete, bool async = true) { //Cache current LOD _lastGeneratedLodLevel = GetLodLevel(); MeshManager.LodLevel = _lastGeneratedLodLevel; if (async) { MeshManager.CreateHeightmapAsync(() => { MeshManager.CreateMesh(); PostCreateMeshGenerate(); if (onComplete != null) { onComplete(); } }); } else { MeshManager.CreateHeightmap(); MeshManager.CreateMesh(); PostCreateMeshGenerate(); if (onComplete != null) { onComplete(); } } }