Hi I’m currently implementing an app dor android and IOS and I had some question for the community.
From what I heard the system that unity uses is a little buggy and unreliable with complex data structure and custom classes, however some of the tutorial and documentation that I read seems a little out of date so I was wondering:
Is [Serializable] still used (I can find only [System.serializable] from C# and [SerializableField] of Unity) or did I need to use only [SerializableField] for every field I want serialized ?
Serialize a list of custom classes still does cause an infinite loop?
If the serialize of unity doesn’t work can you link a serialize tutorial or an article so I can implement my own methods ?
[Serializable] is [System.Serializable], if you are including the System namespace with “using System;”, which some people like to do. That will make it so that every public possible-to-serialize field will be serialized automatically, so no need for the [SerializeField] attribute (you only use that with private fields you also want to serialize). Serializing lists of custom classes if fine, provided that the classes in the list are marked as [Serializable] in their own scripts.
I haven’t noticed anything really buggy about Unity’s serialization. It might not do everything you want it to do, and it’s a long process to really understanding it, but it does the things it’s supposed to. Not being able to use non-built-in structs is sort of annoying, but we all got over it pretty quick. There are situations where a struct is better than a class, but there aren’t any situations where a struct is necessary.