Search Issue Tracker
Won't Fix
Votes
0
Found in
2022.1.21f1
2022.2.0b13
2023.1.0a17
Issue ID
UUM-25388
Regression
Yes
“Error building player because script class layout is incompatible between the editor and the player.“ error when trying to build on WebGL
How to reproduce:
1. Open the attached user project
2. Build And Run (File > Build And Run)
Expected result: Project is built (or no “script class layout is incompatible between the editor and the player.” error when trying to build)
Actual result: “Error building player because script class layout is incompatible between the editor and the player.“ error in the Console
Reproducible with: 2022.1.0a3, 2022.1.21f1, 2022.2.0b13, 2023.1.0a17
Not reproducible with: 2021.3.12f1, 2022.1.0a2
Can’t with test: 2020.3.41f1 (Errors in Console)
Reproducible on: macOS 12.5 (Intel)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [VFX Graph] Base Color Map Inconsistency between Lit and Unlit Ouput
- [HDRP] Water is using the wrong depth when calculating absorption for alpha clipped transparents with depth prepass enabled
- [VFX Graph] Emissive isn't working with Decal output
- Gizmos are not drawn in Game view and Render Graph Execution errors are shown when stacked Overlay Camera is used and 'Compatibility Mode' is disabled
- Crash on WalkTypeTreeInternal when selecting the Texture of a specific FBX
Resolution Note:
Hello!
I've been looking into this bug and it looks like what's happening is that you have a serialized field that should be non-serialized, in this specific case in your BuildAssetBundlesProcessor.BuildPlayerHandler method which has this line:
pOptions.scenes = BuildSettings.GetBuildScenes().
BuildSettings is a scriptable object that has serialized SceneAsset[] buildScenes variable. When I change that to [NonSerialized], that fixes the issue.
When serializing data from the editor to the player, we run a verification step that makes sure that the player doesn't have any serializable fields that the editor doesn't know about. This is because the player would crash if it tried deserializing a data stream that had a missing field (and the editor cannot put any data in there because it has no idea what that field is).
Interestingly, I ran into issues reproducing the error message that you got, but I believe that if you look at the rest of the error message, it would point you to the field that doesn't exist in the editor but does in the player.
I hope this helps, let me know if you have anymore questions :)