Ejemplo n.º 1
0
 /// <summary>
 /// Serialize type and compress it via LZ4. Fills a <paramref name="unityObjects"/> list with the Unity objects
 /// which were referenced during serialization.
 /// </summary>
 /// <param name="value">The value to serialize</param>
 /// <param name="format">The format of serialization</param>
 /// <param name="unityObjects">A list of the Unity objects which were referenced during serialization</param>
 /// <param name="ctx">The context of a given serialization session</param>
 /// <param name="level">Level of compression</param>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static byte[] SerializeValue <T>(T value, DataFormat format, out List <UnityEngine.Object> unityObjects,
                                         SerializationContext ctx = null, OdinLZ4Level level = OdinLZ4Level.FAST) =>
 OdinLZ4Engine.Encode(SerializationUtility.SerializeValue <T>(value, format, out unityObjects, ctx), (LZ4Level)level);
Ejemplo n.º 2
0
 /// <summary>
 /// Decompresses and deserializes a value of a given type from the given byte array in the given format
 /// </summary>
 /// <param name="bytes">The bytes to deserialize from</param>
 /// <param name="format">The format of deserialization</param>
 /// <param name="ctx">The context of a given deserialization session</param>
 /// <typeparam name="TResult"></typeparam>
 /// <returns></returns>
 public static TResult DeserializeValue <TResult>(byte[] bytes, DataFormat format, DeserializationContext ctx = null) =>
 SerializationUtility.DeserializeValue <TResult>(OdinLZ4Engine.Decode(bytes), format, ctx);
Ejemplo n.º 3
0
 /// <summary>
 /// Decompresses and deserializes a value of a given type from the given byte array in the given format,
 /// using the given list of Unity objects for external index reference resolution
 /// </summary>
 /// <param name="bytes">The bytes to deserialize from</param>
 /// <param name="format">The format of deserialization</param>
 /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution</param>
 /// <param name="ctx">The context of a given deserialization session</param>
 /// <typeparam name="TResult"></typeparam>
 /// <returns></returns>
 public static TResult DeserializeValue <TResult>(byte[] bytes, DataFormat format,
                                                  List <UnityEngine.Object> referencedUnityObjects, DeserializationContext ctx = null) =>
 SerializationUtility.DeserializeValue <TResult>(OdinLZ4Engine.Decode(bytes), format, referencedUnityObjects, ctx);