Get as Byte Stream

At times, we don't always need to save to persistent or local storage. We many need to pass the serialized data to a remote server over network. In that case we provide couple of methods to achieve this task.

You can use these methods to save your data to cloud and sync across all your devices.

SerializeToByteArray

This serializes any data passed and returns a byte array.

Examples

Save Int

byte[] data = SerializationManager.SerializeToByteArray<int>(123);

Save Float

byte[] data = SerializationManager.SerializeToByteArray<float>(111.11f);

Save Double

byte[] data = SerializationManager.SerializeToByteArray<double>(129.0);

Save String

byte[] data = SerializationManager.SerializeToByteArray<string>("string value");

Save GameObject

byte[] data = SerializationManager.SerializeToByteArray<GameObject>(gameObjectInstance);

Save List

List<GameObject> gameObjectsList = new List<GameObject>();
....
....
....
byte[] data = SerializationManager.SerializeToByteArray<List<GameObject>>(gameObjectList);

Last updated