Ejemplo n.º 1
0
 /// <summary>
 /// 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>
 /// <typeparam name="T">The type to deserialize.</typeparam>
 /// <param name="bytes">The bytes to deserialize from.</param>
 /// <param name="format">The format to read.</param>
 /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution.</param>
 /// <param name="context">The context to use.</param>
 /// <returns>
 /// The deserialized value.
 /// </returns>
 public static T DeserializeValue <T>(byte[] bytes, DataFormat format, List <UnityEngine.Object> referencedUnityObjects, DeserializationContext context = null)
 {
     using (var stream = CachedMemoryStream.Claim(bytes))
     {
         return(DeserializeValue <T>(stream.Value.MemoryStream, format, referencedUnityObjects, context));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deserializes a value of a given type from the given byte array in the given format.
 /// </summary>
 /// <typeparam name="T">The type to deserialize.</typeparam>
 /// <param name="bytes">The bytes to deserialize from.</param>
 /// <param name="format">The format to read.</param>
 /// <param name="context">The context to use.</param>
 /// <returns>
 /// The deserialized value.
 /// </returns>
 public static T DeserializeValue <T>(byte[] bytes, DataFormat format, DeserializationContext context = null)
 {
     using (var stream = CachedMemoryStream.Claim(bytes))
     {
         return(DeserializeValue <T>(stream.Value.MemoryStream, format, context));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deserializes a value from the given byte array in the given format, using the given list of Unity objects for external index reference resolution. This might fail with primitive values, as they don't come with type metadata.
 /// </summary>
 /// <param name="bytes">The bytes to deserialize from.</param>
 /// <param name="format">The format to read.</param>
 /// <param name="referencedUnityObjects">The list of Unity objects to use for external index reference resolution.</param>
 /// <returns>
 /// The deserialized value.
 /// </returns>
 public static object DeserializeValueWeak(byte[] bytes, DataFormat format, List <UnityEngine.Object> referencedUnityObjects)
 {
     using (var stream = CachedMemoryStream.Claim(bytes))
     {
         return(DeserializeValueWeak(stream.Value.MemoryStream, format, referencedUnityObjects));
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Serializes the given value using the specified format and returns the result as a byte array.
 /// </summary>
 /// <typeparam name="T">The type of the value to serialize.</typeparam>
 /// <param name="value">The value to serialize.</param>
 /// <param name="format">The format to use.</param>
 /// <param name="unityObjects">A list of the Unity objects which were referenced during serialization.</param>
 /// <param name="context">The context to use.</param>
 /// <returns>A byte array containing the serialized value.</returns>
 public static byte[] SerializeValue <T>(T value, DataFormat format, out List <UnityEngine.Object> unityObjects, SerializationContext context = null)
 {
     using (var stream = CachedMemoryStream.Claim())
     {
         SerializeValue(value, stream.Value.MemoryStream, format, out unityObjects, context);
         return(stream.Value.MemoryStream.ToArray());
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Serializes the given value using the specified format, and returns the result as a byte array.
 /// </summary>
 /// <typeparam name="T">The type of the value to serialize.</typeparam>
 /// <param name="value">The value to serialize.</param>
 /// <param name="format">The format to use.</param>
 /// <param name="context">The context to use.</param>
 /// <returns>A byte array containing the serialized value.</returns>
 public static byte[] SerializeValue <T>(T value, DataFormat format, SerializationContext context = null)
 {
     using (var stream = CachedMemoryStream.Claim())
     {
         SerializeValue(value, stream.Value.MemoryStream, format, context);
         return(stream.Value.MemoryStream.ToArray());
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Serializes the given value using the specified format, and returns the result as a byte array.
 /// </summary>
 /// <param name="value">The value to serialize.</param>
 /// <param name="format">The format to use.</param>
 /// <param name="unityObjects">A list of the Unity objects which were referenced during serialization.</param>
 /// <returns>A byte array containing the serialized value.</returns>
 public static byte[] SerializeValueWeak(object value, DataFormat format, out List <UnityEngine.Object> unityObjects)
 {
     using (var stream = CachedMemoryStream.Claim())
     {
         SerializeValueWeak(value, stream.Value.MemoryStream, format, out unityObjects);
         return(stream.Value.MemoryStream.ToArray());
     }
 }