Beispiel #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);
    }
Beispiel #2
0
 public void ApplyToGeom(GeomDataJson parent)
 {
     if (parent != null && parent.Instance != null)
     {
         Instance.transform.parent = parent.Instance.transform;
     }
     else
     {
         Instance.transform.parent = null;
     }
     Instance.transform.localPosition = Position;
     Instance.transform.localRotation = Rotation;
     Instance.transform.localScale    = Scale;
 }
Beispiel #3
0
    public static GeomDataJson GetGeomDataJson(Transform t)
    {
        GeomDataJson geomDataJson = new GeomDataJson();

        geomDataJson.ResourceName = GetResourceName(t);
        if (t.parent != null)
        {
            geomDataJson.ParentName = GetResourceName(t.parent);
        }
        else
        {
            geomDataJson.ParentName = "";
        }
        geomDataJson.Position = t.localPosition;
        geomDataJson.Scale    = t.localScale;
        geomDataJson.Rotation = t.localRotation;
        return(geomDataJson);
    }
Beispiel #4
0
    public static GameObject CreateGeom(GeomDataJson gd)
    {
        GameObject result  = null;
        Object     @object = Resources.Load(ResPath + gd.ResourceName);

        if (@object != null)
        {
            DisneyMobile.CoreUnitySystems.Logger.LogWarning(null, "Geom found " + gd.ResourceName);
            GameObject gameObject = @object as GameObject;
            if (gameObject != null)
            {
                result = Object.Instantiate(gameObject);
            }
        }
        else
        {
            DisneyMobile.CoreUnitySystems.Logger.LogWarning(null, "Geom not found " + gd.ResourceName);
        }
        return(result);
    }
Beispiel #5
0
 public GeomDataJson GetGeomDataJson()
 {
     return(GeomDataJson.GetGeomDataJson(base.transform));
 }