- changed status to resolved
Odin clear List<List<int>> when start game
Issue #214
resolved
Hi, i create simple script which have one field:
List<List<int>> _nestedList = new List<List<int>>();
Then, i attach this script to empty object and create in inspector 1 main list and one nested list with int. Then i start game and when game started this lists is cleared by odin.
Unity version is 2017.1.0p5
Comments (1)
-
- Log in to comment
Thanks for reporting, nice catch!
This happens because Odin incorrectly guesses that Unity is able to serialize it, which it apparently isn't. This is fixed in the next patch.
So if you are inheriting from MonoBehaviour, the expected behavior would be that the list wouldn't be shown in the inspector at all, because nothing would serialize it.
So to fix it, you need to inherit from SerializeMonoBehaviour, in order to enable Odin serialization. And then you need to apply the NonSerialized attribute which tells Odin that Unity won't be serializing it, and then apply the OdinSerialize attribute in order to tell Odin to serialize it.
In the next patch, you can then remove both attributes.