Exemplo n.º 1
0
 public override object Deserialize(JsonHelperReader json, object obj)
 {
     return(new DictionaryEntry(
                json.ReadRawProperty("key"),
                json.ReadRawProperty("value")
                ));
 }
Exemplo n.º 2
0
    public override object Deserialize(JsonHelperReader json, object obj)
    {
        Vector2 v = (Vector2)obj;

        v.Set(
            (float)(double)json.ReadRawProperty("x"),
            (float)(double)json.ReadRawProperty("y")
            );
        return(v);
    }
Exemplo n.º 3
0
    public bool DeserializeMain(JsonHelperReader json, GameObject go)
    {
        go.name = (string)json.ReadRawProperty("name");

        json.Global[go.name] = go;
        json.Global[go.transform.GetPath()] = go;

        go.tag   = (string)json.ReadRawProperty("tag");
        go.layer = (int)(long)json.ReadRawProperty("layer");
        return((bool)json.ReadRawProperty("activeSelf"));
    }
Exemplo n.º 4
0
    public override object Deserialize(JsonHelperReader json, object obj)
    {
        Quaternion q = (Quaternion)obj;

        q.Set(
            (float)(double)json.ReadRawProperty("x"),
            (float)(double)json.ReadRawProperty("y"),
            (float)(double)json.ReadRawProperty("z"),
            (float)(double)json.ReadRawProperty("w")
            );
        return(q);
    }
Exemplo n.º 5
0
    public override object Deserialize(JsonHelperReader json, object obj)
    {
        Component c = (Component)obj;

        string componentType = (string)json.ReadRawProperty(JSONHelper.META.TYPE);

        if (componentType == JSONHelper.META.COMPONENTTYPE_DEFINITION)
        {
            return(Deserialize_(json, c));
        }

        if (componentType == JSONHelper.META.COMPONENTTYPE_REFERENCE)
        {
            string     name    = (string)json.ReadRawProperty("name");
            string     path    = (string)json.ReadRawProperty("path");
            GameObject holding = null;
            object     holdingObj;
            if (json.Global.TryGetValue(path, out holdingObj))
            {
                holding = holdingObj as GameObject;
            }
            if (json.Global.TryGetValue(name, out holdingObj))
            {
                holding = holdingObj as GameObject;
            }
            else
            {
                holding = GameObject.Find(path);
            }
            if (holding == null)
            {
                Console.WriteLine("WARNING: Could not find GameObject " + path + " holding " + _T.Name + "!");
                return(null);
            }
            return(holding.GetComponent(_T));
        }

        throw new JsonReaderException("Unknown component type: " + componentType);
    }
Exemplo n.º 6
0
    public virtual object Deserialize(JsonHelperReader json, object obj)
    {
        if (obj is UnityEngine.Object && !(obj is Component))
        {
            ((UnityEngine.Object)obj).name = (string)json.ReadRawProperty("name");
        }

        while (json.TokenType != JsonToken.EndObject)
        {
            Deserialize(json, obj, json.ReadPropertyName());
        }

        return(obj);
    }
Exemplo n.º 7
0
    public override object Deserialize(JsonHelperReader json, object obj)
    {
        Texture t = null;

        string name = (string)json.ReadRawProperty("name");
        string type = (string)json.ReadRawProperty("type");
        bool   mipmaps, readwrite;

        if (type == "2D")
        {
            TextureFormat format = json.ReadProperty <TextureFormat>("format");
            mipmaps   = (bool)json.ReadRawProperty("mipmaps");
            readwrite = (bool)json.ReadRawProperty("readwrite");

            obj = t = new Texture2D(2, 2, format, mipmaps);
        }
        else
        {
            throw new JsonReaderException("Texture types other than Texture2D not supported!");
        }

        t.name = name;

        if (t is Texture2D)
        {
            Texture2D t2D = (Texture2D)t;

            string dumppath = null;
            string @in      = (string)json.ReadRawProperty(JSONHelper.META.EXTERNAL_IN);
            string path     = (string)json.ReadRawProperty(JSONHelper.META.EXTERNAL_PATH);
            if (@in == JSONHelper.META.EXTERNAL_IN_SHARED && JSONHelper.SharedDir != null)
            {
                dumppath = Path.Combine(JSONHelper.SharedDir, "Texture2Ds");
            }
            else if (@in == JSONHelper.META.EXTERNAL_IN_RELATIVE && json.RelativeDir != null)
            {
                dumppath = json.RelativeDir;
            }
            if (dumppath == null)
            {
                t2D.Apply(mipmaps, !readwrite);
                return(t2D);
            }

            dumppath = Path.Combine(dumppath, path);
            if (!File.Exists(dumppath))
            {
                return(t2D);
            }
            t2D.LoadImage(File.ReadAllBytes(dumppath), false);
            t2D.Apply(mipmaps, !readwrite);
            return(t2D);
        }

        return(t);
    }
Exemplo n.º 8
0
 public override object Deserialize(JsonHelperReader json, object obj)
 {
     ((patch_TextAsset)obj).textOverride = (string)json.ReadRawProperty("text");
     return(obj);
 }