I’ve asked on the Unity forums, and got a response. My question:
I’m using Aron Granberg’s A* Pathfinding project in my game. It generated navmeshes at runtime by examining the colliders in the scene when the scene loads. This was working fine under ProBuilder 4.2, but as of ProBuilder 4.3, I’m getting very inconsistent results when the navmesh is built at runtime. Specifically, if it’s built when the scene first loads.
Given the changes to ProBuilder’s mesh as of 4.3, is ProBuilder now generating the mesh at Start or Awake? Is something new happening at Start/Awake that would cause some PB Objects’ colliders to potentially not exist at Start, if other code is called before PB’s scripts complete their Start/Awake methods?
If PB is now generating colliders at start/awake (which is the same time that A* is generating a navmesh from the active colliders in the scene), can I use Script Execution Order to ensure that the appropriate PB scripts are run before other scripts are run? If so, which scripts should I use?
And here’s the response from the ProBuilder dev:
To answer narrowly, you can set the Script Execution Order to run
ProBuilderMesh components first.
To answer more broadly, ProBuilder shouldn’t be generating meshes on Awake except in the case of prefab instantiation. I have filed a bug to this effect.
Unfortunately, I tried placing ProBuilderMesh at the top of the Script Execution Order, but it doesn’t change the behavior.
Here’s the navmesh when I manually scan it:
And here’s what it looks like after starting the game, when Scan on Awake is enabled:
The scan picked up a few meshes, but most of the meshes were ignored. Those curved pieces are ProBuilder objects, and those got picked up. The other non-curved pieces are not PB objects, so it’s no surprise that those got picked up. But basically every other room got ignored by the navmesh. If, after the game starts, I immediately perform another manual scan of the graph, it scans correctly, resulting in the first image.
Again, this only started occurring with the latest version of ProBuilder (4.3-preview). Everything was fine under 4.2. I don’t know how much you’ll be able to investigate this, but I assume a fair number of people use ProBuilder, and that this will become more of an issue when 4.3-preview comes out of preview.