Search Unity

Jobs-friendly version of UpdateNavMeshDataAsync/BuildNavMeshDataAsync ?

Discussion in 'Navigation' started by burningmime, Jun 5, 2020.

  1. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    I'm generating a mesh at runtime. I use a series of jobs dependent on one another to build up various types of data, then combine them into index and vertex buffers. All this can be done asynchronously. However, if I want to add a nav mesh, I need to have a "sync point" in the main thread where I call BuildNavMeshDataAsync. For example, I can do something like this:

    * On frame 1, start my jobs using `.Schedule()`
    * On frame 2, call `.Complete()`, build meshes, then call `BuildNavMeshDataAsync`
    * On frame 3+ begin awaiting the results of the nav mesh operation

    However, I'm wondering if there's a way that I can tie it in with my existing job dependencies?
     
    Last edited: Jun 5, 2020
  2. Simeon

    Simeon

    Joined:
    Sep 26, 2012
    Posts:
    50
    I was wondering the same thing. Jobs depend on the nav mesh query and the query is created on the main thread only, so you can't start jobs before the nav mesh update is done as the query will get invalidated white jobs are running if you call the `BuildNavMeshDataAsync` method.