Ejemplo n.º 1
0
    public static GameObject Deserialize(byte[] data)
    {
        string            @string      = Encoding.ASCII.GetString(data);
        GeomListJson      geomListJson = GeomListJson.Deserialize(@string);
        List <GameObject> list         = new List <GameObject>();

        foreach (GeomDataJson geom in geomListJson.Geoms)
        {
            GameObject gameObject = (geom.Instance = CreateGeom(geom));
            if (gameObject != null)
            {
                list.Add(gameObject);
            }
        }
        foreach (GeomDataJson geom2 in geomListJson.Geoms)
        {
            if (geom2.Instance != null && !string.IsNullOrEmpty(geom2.ParentName))
            {
                GeomDataJson geomDataJson = geomListJson.FindByResourceName(geom2.ParentName);
                if (geomDataJson != null)
                {
                    geom2.ApplyToGeom(geomDataJson);
                }
            }
        }
        return(geomListJson.FindRoot().Instance);
    }
Ejemplo n.º 2
0
    public static byte[] Serialize(GameObject obj)
    {
        GeomSerializer[] componentsInChildren = obj.GetComponentsInChildren <GeomSerializer>();
        GeomListJson     geomListJson         = new GeomListJson();

        GeomSerializer[] array = componentsInChildren;
        foreach (GeomSerializer geomSerializer in array)
        {
            geomListJson.Geoms.Add(geomSerializer.GetGeomDataJson());
        }
        string text = geomListJson.Serialize();

        Debug.LogError(text);
        return(Encoding.ASCII.GetBytes(text));
    }