Binary, XML and JSON (Only for Unity) Serialization
- using RedHeliumGames.IO namespace
- Create an instance of the FileManager class.
- Call Save(T data) function for save your serialization object
- Call T Load() function for load your serialization object from file
//This is example serialization structure
[Serializable]
public struct TestStruct
{
public int a;
public string b;
public TestStruct(int a, string b)
{
this.a = a;
this.b = b;
}
}
private void Start()
{
// Create FileManager
FileManager fileManager = new FileManager(Path.Combine(Application.dataPath, "test123.bin"),
FileManager.SerializerType.Binary);
//Initialize testing serialization object
test = new TestStruct() { a = 25, b = "Hello" };
//Save our structure
fileManager.Save(test);
// Output loaded data from file
print(fileManager.Load<TestStruct>().a);
}