Search Issue Tracker
Not Reproducible
Votes
10
Found in
5.6.1f1
Issue ID
922226
Regression
No
Serialized Scriptable Object works in the Editor, but not in the Build
To reproduce:
1. Open the "Game" scene in the attached project
2. Play the scene
3. Press any key
4. Click on the blue squares on the "Sector A1" area to observe the desired navigation
5. Build and Run the scene
Desired outcome: Navigation (step 4) on the Build produces the same behaviour as in the Editor
Actual result: The "Sector A1" area shows no image, pressing blue squares for navigation results in "NullReferenceException"
Note: When running the Build, the following console message appears:
"A script behaviour (script unknown or not yet loaded) has a different serialization layout when loading. (Read 48 bytes but expected 88 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?"
Reproduced with 5.6.1f1, 5.6.2f1, 2017.1.0a1, 2017.1.0f1, 2017.2.0b1
Could not test on 5.4, 5.5 due to console errors
Note: On 2017.2.0b1 due to scripts and assemblies that use obsolete APIs, some Game Objects are not visible, but the message about "different serialization layout when loading" is still reproducible in the Build.
Comments (1)
-
polysoft3D
Sep 12, 2018 15:13
2018.2.3f1 not work in the build
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
- Freeze on DynamicHeapAllocator::InitializeMemoryRegion when entering Play mode in a specific scene
- Memory usage rises when switching scenes with GRD enabled and a loaded texture in URP
- [Quality Hackweek] Terrain Brush Size value is not serialized after deselecting the terrain when using the first instance of multiple Inspectors
- "NullReferenceException" is thrown when setting a long string in TMP with "Atlas Population Mode" set to "Dynamic" and "Multi Atlas Textures" enabled
- TextMeshPro text is misaligned when alignment is set via script
Resolution Note:
The problem here is that the ScriptableObject asset was created using a class inside a file that didn't match the class name. This is a rule in Unity, because of how assets are referencing their MonoScript asset.
In order to circumvent this, an error dialog will pop up when trying to assign a ScriptableObject asset that has been created from a mismatching file.