Unity AI Navigation NavMesh Serialization Layout Error

153 Views Asked by At

I'm getting this error in Android build not editor:

Error: A scripted object (probably Unity.AI.Navigation.NavMeshSurface?) has a different serialization layout when loading. (Read 32 bytes but expected 124 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

UnityEngine.Resources:Load(String)

What could be causing the problem? How can I solve this bug?

1

There are 1 best solutions below

0
Harun On

A bug in Unity's Nav Mesh package: There are serialized properties within the script in the UNITY_EDITOR blog. Due to this, when building, those properties are not compiled, naturally causing a mismatch with script properties. My own solution was as follows: I added NavMeshSurfaces at runtime using AddComponent and provided the baked data after adding the NavMeshSurface. This way, the problem was resolved. Until this bug in the Unity AI Navigation package is fixed, I would appreciate it if anyone has a better solution to share.