Search Issue Tracker
Won't Fix
Votes
0
Found in
2021.2.0a18
2021.2.5f1
2022.1
Issue ID
1387211
Regression
Yes
Error is thrown when attempting to serialize System.Random
Reproduction steps:
1. Open the attached project "Case_1387211.zip" and load Scene "SampleScene"
2. Enter Play Mode
3. Observe the Console
Expected result: No errors are thrown in the Console
Actual result: The following error is thrown in the Console:
"SerializationException: Type 'System.Random' in Assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."
Reproducible with: 2021.2.0a18, 2021.2.5f1, 2022.1.0b1
Not reproducible with: 2020.3.24f1, 2021.2.0a17
Comments (1)
-
where-to-watch-ant-man-and-the-wasp-quantumania-free-online
Feb 17, 2023 17:05
This is something Microsoft removed from the base class libraries that Unity uses
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
- Crash on GUIManager::DoGUIEvent when focusing on the Game view window on a specific project
- Asset creation in the Project Browser is not always undone/inconsistent when the undo shortcut is pressed right after creating an asset
- JobTempAlloc memory leak warning is thrown when the Player is shut down
- Graphics State Collection warm-up does not work when using with Addressables Shaders
- "Baked Shadow Radius" field is visible but inactive when when the Shadow Type is set to "Hard Shadows" under the Light Component
Resolution Note (2022.2.X):
Unfortunately, we no longer support the serialization of objects of type System.Random with the BinaryFormatter. This is something Microsoft removed from the base class libraries that Unity uses - with an update to newer base class libraries Unity picked up this behavior.
There is a good bit of discussion around this topic here: https://github.com/dotnet/runtime/issues/27429 (including some possible work arounds).