- A* version: 5.2.2
- Unity version: 2022.3.35f1
We’re getting a lot of false positives when tearing down (and to some extent when instantiating) prefabs in our scenes. Where the prefab contains RecastNavmeshModifier
that are non-dynamic. The error is "The RecastNavmeshModifier has been moved or resized since it was enabled..."
The cause seem to be that a parent game object starts out as enabled, trickling down to the RecastNavmeshModifier
components OnEnabled
which grabs the bounds of a collider. The parent game object is later disabled. Again causing a event chain to reach OnDisabled
on the RecastNavmeshModifier
, which again grabs the bounds based on the same collider. The only problem is that due to the parent object being disabled, the collider will always report a zero-size bounds (see the note in Unity Collider documentation). Which subsequently triggers the error.
Maybe make this error logging optional?
Hi there, I’ll go ahead and tag @aron_granberg on this and see what he think of this suggestion
Thanks for letting us know!
Dont know if this is a magic Unity thing. Tried to reproduce in a smaller test project without much success.
In our main project, the prefabs we spawn are quite large (game object and component wise) and the spawn order etc is rather lenghty and complicated (it goes on for a few seconds). The collider info retrieved via the CalculateBounds
call in NavmeshRecastModifier
differs in the collider bounds center. It seem to be random (does not trigger predictably). The center position is almost the same during OnEnabled
and OnDisabled
, but big enought to trigger the error log.
And no, nowhere in our codebase do we move the spawned prefabs (unless you count providing position and rotation during instantiation).
This could happen due to static batching. Are you using static batching for some of these objects?
Nope, no static batching involved. The whole enable/disable flipping is done in our level generator logic (which turns connecting elements, such as walls/doors etc, on/off between placed modules in the level). Which runs in the Start method (which returns a IEnumerator in our case to spread the generator stuff over several seconds)
For now I’ve just removed the whole if (!this.dynamic)
check/scope in OnDisable