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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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 :)