Auto-bake edited NavigationPolygons in the Editor on a timer #87504
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Auto-bakes edited NavigationPolygons in the Editor on a timer.
The pre-4.2 NavigationRegion2D did automatically rebake the entire NavigationPolygon everytime it was changed even a little.
This caused severe performance problems while editing more complex polygons.
Baking a navigation mesh is not exactly a quick process. It was very noticeable while developing the 2D navigation mesh baking with the Editor freezing all the time while dragging outline points. That was the reason why with 4.2. this auto-bake was removed from the Editor. It was expected that now with the 2D navigation mesh very complex polygons will be far more common then before and users will complain about this performance problem.
That is also what happened (the complex polygon part) but now some users started to miss the convenience of the old feature and want it back. If they only have simple projects it was convenient to not hit the bake button all the time to see how things turn out when baked. It is also regularly confusing new users that do not understand why there is no polygon, not having discovered the bake button yet.
So this pr adds back the auto-bake on a timer that refreshes on every change before firing the bake. By default 1.5 seconds which gives enough time to drag around multiple polygon outline points without triggering the bake. The timer can be adjusted in the EditorSettings. By turning it down to 0.0 seconds the old instant-bake is back. By going negativ <0 with the timer it gets disabled completely again. Slower users that need more time to arrange things can increase the timer near infinite, so the feature stays accesible.
I think this solves the issue for all the 3 major user groups.