public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { if (obj is IPersistentUnityObject) { if (obj is PersistentAssetToken) { (obj as PersistentAssetToken).OnSerialize(info, context); } else if (obj is IPersistentAsset) { if (_proxy == null) { _proxy = new AutoPersistentAssetToken(); } info.SetType(typeof(AutoPersistentAssetToken)); _proxy.SetObject(obj as IPersistentAsset); _proxy.OnSerialize(info, context); _proxy.SetObject(null); } else if (obj is PersistentObject) { (obj as PersistentObject).OnSerialize(info, context); } else { throw new SerializationException("IPersistentUnityObjects should be handled by an IPersistentAsset, not directly by the serializtion engine."); } } else { SimpleUnityStructureSurrogate.AddValue(obj, info, context); } }
internal static bool AddValue(object obj, SerializationInfo info, StreamingContext context) { if (obj is UnityEngine.Vector2) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.Vector2)obj); return(true); } else if (obj is UnityEngine.Vector3) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.Vector3)obj); return(true); } else if (obj is UnityEngine.Vector4) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.Vector4)obj); return(true); } else if (obj is UnityEngine.Quaternion) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.Quaternion)obj); return(true); } else if (obj is UnityEngine.Color) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.Color)obj); return(true); } else if (obj is UnityEngine.LayerMask) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.LayerMask)obj); return(true); } else if (obj is UnityEngine.Matrix4x4) { SimpleUnityStructureSurrogate.AddValue(info, (UnityEngine.Matrix4x4)obj); return(true); } return(false); }
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { SimpleUnityStructureSurrogate.AddValue(obj, info, context); }