Search Issue Tracker
By Design
Votes
0
Found in
2018.4.0f1
2019.2.0a1
2019.2.0f1
2019.3.0a1
2020.1.0a1
Issue ID
1185356
Regression
No
Hash128.Parse throws an Exception when running in a thread other than the main thread in Unity Editor
To reproduce:
1. Download attached "Repro_Hash128_Parse.zip" project and open in Unity
2. Open "SampleScene"
3. Select "Hash128" gameObject in Hierarchy
4. In Inspector press "Parse in main thread" button
5. Observe that everything works as Expected
6. Press "Parse in thread pool" button
Expected results: As before everything works as Expected - Hash is printed and no Errors are logged
Actual results: Inspector throws an Exception:
"UnityEngine.UnityException: Parse can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at (wrapper managed-to-native) UnityEngine.Hash128.Parse_Injected(string,UnityEngine.Hash128&)
at UnityEngine.Hash128.Parse (System.String hashString) [0x00000] in <15966b0e0b01470ab47c749d344008bb>:0
at Hash128ParserEditor.ParseHash () [0x00013] in /Users/jonas/Downloads/case_1185356-Repro_Hash128_Parse/Assets/Editor/Hash128ParserEditor.cs:38
UnityEngine.Debug:Log(Object)
Hash128ParserEditor:ParseHash() (at Assets/Editor/Hash128ParserEditor.cs:43)
Hash128ParserEditor:<OnInspectorGUI>b__2_0(Object) (at Assets/Editor/Hash128ParserEditor.cs:27)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()"
Notes:
- This issue happens on both Windows and macOS
- Could not check on older Unity versions than 2018.3 because of old C# version
Reproduced on Unity 2018.4.10f1, 2019.2.7f2, 2019.3.0b5 and 2020.1.0a5
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
- UI Builder can't set a background image to a sprite from a multi-sprite spritesheet in the Resources folder
- Light2D freeform does not render the internal part when rendered in certain shapes
- Using AddCopyPass causes an incorrect merging of passes.
- Negative Enum value is not pasted correctly when copying from another array
- Silent Crash when generating Lightmap UVs for a model with a large object scale
Resolution Note (2020.1.X):
This API is meant to work only on the main thread since Unity API is not thread safe.