unity – Is there built-in way to restrict a `NavMeshAgent` to a specific area on a`NavMesh`?

I have an object with a NavMeshAgent that wanders around. It gets a random waypoint, moves to it, then waits a little while and repeats this process.

I would like to restrict this object to a specific area instead of having it aimlessly wander all over the world. To do this, I currently just get a new random waypoint within a specific distance of the object’s spawn point:

private Vector3 _spawnPoint; // Set to transform.position on awake.
public Vector3 GetNewWaypoint() {
    var randomOffset = Random.insideUnitSphere * MaximumRouteDistance;
    NavMesh.SamplePosition(_spawnPoint + randomOffset, out NavMeshHit navHit, MaximumRouteDistance, NavigationSamplerLayer);
    return navHit.position;
}

While this works, I can’t help but feel like people much smarter than myself have already created a solution inside of Unity so that I don’t have to do it with ancient technology.


Is there a way, built into Unity, to restrict a NavMeshAgent to a specific area on aNavMesh?

Note: I excluded the c# tag because I prefer an answer that doesn’t require additional code; though I’m not against adjusting my solution to support the Unity intended method.