I am having some problems storing information. The problem comes because when saving lists I get very long strings even if the information looks short.
Lets say I have 100 houses and I want to save how many people are on each house. I use this:
Houses.cs
[System.Serializable]
public class Houses
{
public int ID { get; set; }
public int PEOPLE { get; set; }
public Houses(int _ID, int _PEOPLE)
{
ID = _ID;
PEOPLE = _PEOPLE ;
}
}
Then in another script I have:
public List<Houses> HousesList = new List<Houses>();
void Awake()
{
HousesList.Add(new Houses(0,0));
//repeat until 100 (or more) I use a loop to initialize it
}
Then to add people I say:
HousesList[3].PEOPLE+=5;
Then to save I use the BinaryFormatter/MemoryStream way but even if the list has only one ID and one value for the people the resulting serialized string has 4,000-5,000 characters.
To store a small amount of data I use the same system but only with one List:
Houses.Add(new Houses(0,2,0,0,1)); // house 1, house 2... house 5
But this way even if there are 100 houses the string is short but is confusing with so many numbers. And later I can have problems with save/load if I add more houses.
Is there any way to manage this kind of data and save it in a much shorter string?
Thank you.