Hi everyone, I was wondering what is the best way to save values in Unity?Say like I have a List that I want to save I can’t use playerprefs since it is limited to strings, ints and floats would serialization be the next best thing or should I go for something else?
–Eric
If I use PlayerPrefsX how would I set and get my list? Do I want to use setarray and getarray?
Yes, if by list you mean a generic List, it’s trivial to convert Lists to arrays and back.
–Eric
nvm
Playerprefs is AMAZING and pretty fast specillay if you are using in Desktop. it is not limited. BUT, if you are using IOS/Android and you need to save a huge amount of data. So, XML is your way.
Also, you can write your own saving data tool to save in any file format you need or even you invint. it just need you to have experience is .Net
m;
Are there any cases where a serialization method would be better to use than playerprefs?
If you want the user to edit the data themselves use xml. Apart from that I would go with playerprefs. I use to be rather skeptical of it coming from an application programming background but instead of resisting unity’s way just conform with it.
While the PlayerPrefs is simple and convenient it’s not what I’m looking for. I think I would like to use binary serialization.So how would I set that up?
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour{
public int ExampleInt;
public bool ExampleBool;
public float ExampleFloat;
public string ExampleString;
public int[] ExampleArray;
public List<string> ExampleList = new List<string>();
//What comes next?
}
I really need help setting up the binary serialization. I have no clue how to set it up