fullinspector
fullinspector copied to clipboard
FullInspector with Json.NET as the default serializer : empty data with Resources.Load()
Hello guys,
I don't know if anyone here will be able to help me. Have you ever used FullInspector with Json.NET as the default serializer ?
I'm trying to switch to Json.NET as the default serializer for deserialization performance : to optimize loading time !
Having Json.NET as the default serializer for FullInspector causes a bug for data serialized in a BaseBehavior and loaded using Resources.Load() : the data is empty ! This bug can be reproduced on device (Android) systematically, and on Unity Editor (following the steps I provide).
I'm using Unity 2017.1.1p4, but I also tested the same sample project with Unity 5.4.5p2 (bug is here too with that version as well).
https://drive.google.com/file/d/1gDncGD_SEwKNlhYo-83iRocFSB3cMQSD/view?usp=sharing Sample project with just FullInspector 2.6.8 setup to reproduce the bug. Here are the steps :
- Open the project then open the "MainScene".
- Close Unity completely. (This step is important)
- Open Unity and the project again, and the "MainScene" should be the default loaded scene.
- Press play and notice the "data.Resources == null !!!" log. The data is empty.
- Stop the game, and go click on the prefab "Data" in the "Resources" directory to display it in the inspector : Everything is displayed fine.
- Press play again and notice the logs : the data is now read perfectly.
Any idea what might be causing this bug ?
Thank you for your time guys !
Cheers, Alex
Hi @champi
I stumbled on the same issue. Did you have any luck finding a fix ?
Cheers,
Any news about this ? I updated my project to Unity 2017 and I'm having the same issue.
Hi Guys,
Apparently this is due to the fact that the implementation of JsonNetSerializer does not support multithreading (SupportsMultithreading set to false). Set SupportsMultithreading to true, and you don't have that bug anymore. But you might have other unexpected behaviours, so this is not a good idea.
By the way if you simply set SupportsMultithreading to false in the FullSerializerSerializer class, you get exactly the same bug.
Jacob could tell us more about this, I hope I'm not saying anything stupid :P
So how to get our serialized data using Resources.Load() ? By making sure you instantiate the prefab before attempting to read the data : the Awake() call will deserialize the data for us. Or call fiSerializationManager.OnUnityObjectAwake() yourself before reading the data.
Cheers, Alex