예제 #1
0
        object DeserializeSingleObject(Type type, Type expectedType)
        {
            object obj = CustomDeserializer.CustomDeserialize(package, type, reader);

            if (obj != null)
            {
                return(obj);
            }
            if (typeof(ScriptableObject).IsAssignableFrom(type))
            {
                return(Instantiate(FindAsset(reader.ReadString()), isMain));
            }
            if (typeof(GameObject).IsAssignableFrom(type))
            {
                return(Instantiate(FindAsset(reader.ReadString()), isMain));
            }

            try
            {
                if (package.version < 3 && expectedType != null && expectedType == typeof(Package.Asset))
                {
                    return(reader.ReadUnityType(expectedType));
                }

                return(reader.ReadUnityType(type, package));
            }
            catch (MissingMethodException)
            {
                Util.DebugPrint("Unsupported type for deserialization:", type.Name);
                return(null);
            }
        }
예제 #2
0
        object DeserializeObject(Type type)
        {
            object obj = CustomDeserializer.CustomDeserialize(package, type, reader);

            if (obj != null)
            {
                return(obj);
            }

            obj = Activator.CreateInstance(type);
            reader.ReadString();
            DeserializeFields(obj, type, true);
            return(obj);
        }
예제 #3
0
        UnityEngine.Object DeserializeScriptableObject(Type type)
        {
            object obj = CustomDeserializer.CustomDeserialize(package, type, reader);

            if (obj != null)
            {
                return((UnityEngine.Object)obj);
            }

            ScriptableObject so = ScriptableObject.CreateInstance(type);

            so.name = reader.ReadString();
            DeserializeFields(so, type, false);
            return(so);
        }