jacobdufault / fullinspector

Full Inspector supercharges Unity's inspector
MIT License
111 stars 27 forks source link

FullInspector with Json.NET as the default serializer : empty data with Resources.Load() #213

Open champi opened 6 years ago

champi commented 6 years ago

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 :

Any idea what might be causing this bug ?

Thank you for your time guys !

Cheers, Alex

zarkov commented 6 years ago

Hi @champi

I stumbled on the same issue. Did you have any luck finding a fix ?

Cheers,

chanhpomme commented 6 years ago

Any news about this ? I updated my project to Unity 2017 and I'm having the same issue.

champi commented 6 years ago

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