Bake Navmesh From A Script

So, I have created a mock-up of a simple strategy game and bodged some code together which works well enough. What I have right now is two teams of AIs who fight eachother on a map, or the player can set waypoints for their team to go to. What I want is to randomly generate the map (which I’ve done) however the navmesh, of course, stays the same. Here’s my script:

 using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.AI;
    using UnityEditor;
    
    public class ObstacleSpawner : MonoBehaviour {
    
    	public int MaxX;
    	public int MinX;
    	public int MaxZ;
    	public int MinZ;
    	public GameObject Obstacle;
    	// Use this for initialization
    
    	public void Start () {
    
    		for(int i = 0; i < 100; i++) {
    
    			int X = Random.Range (MinX, MaxX);
    			int Z = Random.Range (MinZ, MaxZ);
    			Instantiate (Obstacle, new Vector3(X, 0f, Z), Quaternion.identity);
    			//<- I want to build the navmesh here.
    
    		}
    
    	}
    
    }

Nevermind, I just gave the ‘obstacle’ a navmesh obstacle component and it works great!