Function NavmeshBase.ToTileMeshes

ToTileMeshes (IntRect? tileRect=null)

Extracts tiles from the graph into a portable format.

Public
TileMeshes ToTileMeshes (

IntRect?

tileRect=null

If specified, only tiles within this rectangle will be extracted. The rectangle is specified in tile coordinates starting at (0,0). If larger than the graph, it will be clamped to the graph's size.

)

Extracts tiles from the graph into a portable format.

Return

The extracted tiles.

This can be used for many things, for example world streaming or placing large prefabs that have been pre-scanned.

The extracted tiles will have the same world-space size as this graph's tiles. Navmesh cuts are not baked into the extracted tiles.

Note

The meshes do not have any information about the graph's settings, they are just lightweight containers for the navmesh data.

var graph = AstarPath.active.data.recastGraph;
var tileMeshes = graph.ToTileMeshes();
// Store as a byte array
var bytes = tileMeshes.Serialize();

// Later on, load it back
var tileMeshes2 = TileMeshes.Deserialize(bytes);

// Load the tiles back into the graph
AstarPath.active.AddWorkItem(() => {
graph.ReplaceTiles(tileMeshes2);
});
AstarPath.active.FlushWorkItems();