internal static object GetValue(object obj, SerializationInfo info, StreamingContext context)
        {
            if (obj is UnityEngine.Vector2)
            {
                return(SimpleUnityStructureSurrogate.GetVector2(info));
            }
            else if (obj is UnityEngine.Vector3)
            {
                return(SimpleUnityStructureSurrogate.GetVector3(info));
            }
            else if (obj is UnityEngine.Vector4)
            {
                return(SimpleUnityStructureSurrogate.GetVector4(info));
            }
            else if (obj is UnityEngine.Quaternion)
            {
                return(SimpleUnityStructureSurrogate.GetQuaternion(info));
            }
            else if (obj is UnityEngine.Color)
            {
                return(SimpleUnityStructureSurrogate.GetColor(info));
            }
            else if (obj is UnityEngine.LayerMask)
            {
                return(SimpleUnityStructureSurrogate.GetLayerMask(info));
            }
            else if (obj is UnityEngine.Matrix4x4)
            {
                return(SimpleUnityStructureSurrogate.GetMatrix4x4(info));
            }

            return(null);
        }
        public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
        {
            if (obj is IPersistantUnityObject)
            {
                if (obj is PersistantAssetToken)
                {
                    (obj as PersistantAssetToken).OnSerialize(info, context);
                }
                else if (obj is IPersistantAsset)
                {
                    if (_proxy == null)
                    {
                        _proxy = new AutoPersistantAssetToken();
                    }

                    info.SetType(typeof(AutoPersistantAssetToken));
                    _proxy.SetObject(obj as IPersistantAsset);
                    _proxy.OnSerialize(info, context);
                    _proxy.SetObject(null);
                }
                else
                {
                    throw new SerializationException("IPersistantUnityObjects should be handled by an IPersistantAsset, not directly by the serializtion engine.");
                }
            }
            else
            {
                SimpleUnityStructureSurrogate.AddValue(obj, info, context);
            }
        }
        public static bool IsSpeciallySerialized(System.Type tp)
        {
            if (tp == null)
            {
                throw new System.ArgumentNullException("tp");
            }

            if (typeof(IPersistantUnityObject).IsAssignableFrom(tp))
            {
                return(true);
            }

            return(SimpleUnityStructureSurrogate.IsSpeciallySerialized(tp));
        }
 public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
 {
     if (obj is IPersistantUnityObject)
     {
         (obj as IPersistantUnityObject).OnDeserialize(info, context, _assets);
         if (obj is AutoPersistantAssetToken)
         {
             return((obj as AutoPersistantAssetToken).PreemptiveCreate());
         }
         return(obj);
     }
     else
     {
         return(SimpleUnityStructureSurrogate.GetValue(obj, info, context));
     }
 }
 public ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
 {
     if (SimpleUnityStructureSurrogate.IsSpeciallySerialized(type))
     {
         selector = this;
         return(this);
     }
     else if (_nextSelector != null)
     {
         return(_nextSelector.GetSurrogate(type, context, out selector));
     }
     else
     {
         selector = null;
         return(null);
     }
 }
        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 object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
 {
     return(SimpleUnityStructureSurrogate.GetValue(obj, info, context));
 }
 public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
 {
     SimpleUnityStructureSurrogate.AddValue(obj, info, context);
 }