// Assuming the SceneNavigation component is attached to this GameObject
var sceneNavigation = GetComponent\<SceneNavigation\>();
// Configure some SceneNavigation settings
sceneNavigation.UseSceneData = true; // Use scene data for NavMesh generation
sceneNavigation.CustomAgent = false; // Use pre-configured agents
// Define navigable surfaces, e.g., floor
sceneNavigation.NavigableSurfaces = MRUKAnchor.SceneLabels.FLOOR;
// Find and assign NavMeshAgents in the scene so that they will be automatically assigned to the NavMesh
sceneNavigation.Agents = new List\<NavMeshAgent\>(FindAnyObjectByType\<NavMeshAgent\>());
// Optionally, handle the NavMesh initialization event
sceneNavigation.OnNavMeshInitialized.AddListener(() =\>
{ Debug.Log("NavMesh has been successfully initialized.");});
// Build the NavMesh for the current scene
sceneNavigation.BuildSceneNavMesh();