My code generates a level by looping through a list of empty game objects and choosing a random object from another list of objects, then instantiating that object at the empty object's position. Then I call BuildNavMesh
on my navmesh surface and it gives me this error:
RuntimeNavMeshBuilder: Source mesh Buildings does not allow read access. This will work in playmode in the editor but not in player
- UnityEngine.AI.NavMeshBuilder:BuildNavMeshData (UnityEngine.AI.NavMeshBuildSettings,System.Collections.Generic.List`1<UnityEngine.AI.NavMeshBuildSource>,UnityEngine.Bounds,UnityEngine.Vector3,UnityEngine.Quaternion)
- Unity.AI.Navigation.NavMeshSurface:BuildNavMesh () (at Library/PackageCache/[email protected]/Runtime/NavMeshSurface.cs:251)
- CityGenerator:Start () (at Assets/CityGenerator.cs:19)
This is the code:
public List<GameObject> cityChunks;
int cityChunk;
public List<GameObject> grid;
public NavMeshSurface surface;
void Start()
{
foreach (GameObject empty in grid)
{
cityChunk = Random.Range(0, cityChunks.Count);
Instantiate(cityChunks[cityChunk], empty.transform.position, Quaternion.identity);
}
surface.BuildNavMesh();
}