//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Runtime.CompilerServices;
using bs;
namespace bs.Editor
{
/** @addtogroup Utility-Editor
* @{
*/
///
/// Container and functionality to creating a serialized version of an object. The object must be of valid serializable
/// type (, or a class/struct marked with
/// attribute).
///
public class SerializedObject : ScriptObject
{
///
/// Constructs a new serialized object. Only for internal runtime use.
///
private SerializedObject()
{ }
///
/// Serializes all data within the provided object.
///
/// Object to serialize.
/// Object containing serialized data.
public static SerializedObject Create(object obj)
{
if (obj == null)
return null;
return Internal_Create(obj);
}
///
/// Deserializes data stored in this object. Components and resources cannot be deserialized.
///
/// Type to cast the object to after deserialization.
/// Deserialized object if successful, null otherwise.
public T Get()
{
return (T) Internal_Deserialize(mCachedPtr);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern SerializedObject Internal_Create(object obj);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object Internal_Deserialize(IntPtr instance);
}
/** @} */
}