Function RecastBuilder.BuildTileMeshes

BuildTileMeshes (RecastGraph graph, TileLayout tileLayout, IntRect tileRect)

Builds meshes for the given tiles in a graph.

Public Static
TileBuilder BuildTileMeshes (

RecastGraph

graph

TileLayout

tileLayout

IntRect

tileRect

)

Builds meshes for the given tiles in a graph.

Call Schedule on the returned object to actually start the job.

You may want to adjust the settings on the returned object before calling Schedule.

// Scans the first 6x6 chunk of tiles of the recast graph (the IntRect uses inclusive coordinates)
var graph = AstarPath.active.data.recastGraph;
var buildSettings = RecastBuilder.BuildTileMeshes(graph, new TileLayout(graph), new IntRect(0, 0, 5, 5));
var disposeArena = new Pathfinding.Jobs.DisposeArena();
var promise = buildSettings.Schedule(disposeArena);

AstarPath.active.AddWorkItem(() => {
// Block until the asynchronous job completes
var result = promise.Complete();
TileMeshes tiles = result.tileMeshes.ToManaged();
// Take the scanned tiles and place them in the graph,
// but not at their original location, but 2 tiles away, rotated 90 degrees.
tiles.tileRect = tiles.tileRect.Offset(new Vector2Int(2, 0));
tiles.Rotate(1);
graph.ReplaceTiles(tiles);

// Dispose unmanaged data
disposeArena.DisposeAll();
result.Dispose();
});