0
\$\begingroup\$

Is there some best practices to serialize objects to file on mobile devices in Unity using C#. I've tried to search it myself, but found only this link. However, it looks like here they are trying to cache AssetBundles. I'm new to Unity, but I have some experience in iOS (swift) development. Here we have opportunity to cache some objects(variables) in local storage, to avoid overusing network. So I wanted to create some static class (for example Storage), which caches variables to file permanently and return them by some key.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

Unity provides a way to save primitive values(float, int, string) by keys using the PlayerPrefs class. https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

For more in depth serialization, like complex objects into a file(byte[]) for reloading later, you can use the [Serializable] annotation to do so. Best practices found in the links below: https://blogs.unity3d.com/2014/06/24/serialization-in-unity/ https://docs.unity3d.com/Manual/script-Serialization.html

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .