Beispiel #1
0
    // convert array of model info to json
    public JObject ToJSON()
    {
        ModelInfoArray modelInfoArray = new ModelInfoArray();

        modelInfoArray.modelInfos = new ModelInfo[modelInfoList.Count];
        for (int i = 0; i < modelInfoList.Count; i++)
        {
            modelInfoArray.modelInfos[i] = modelInfoList[i];
        }

        return(JObject.FromObject(modelInfoArray));
    }
Beispiel #2
0
    // reconstitute the JSON
    public void LoadFromJSON(JToken mapMetadata)
    {
        Clear();

        if (mapMetadata is JObject && mapMetadata[jsonKey] is JObject)
        {
            ModelInfoArray modelInfoArray = mapMetadata[jsonKey].ToObject <ModelInfoArray>();
            if (modelInfoArray.modelInfos == null)
            {
                Debug.Log("No models");
                return;
            }

            // populate the object and info Lists
            foreach (var info in modelInfoArray.modelInfos)
            {
                modelInfoList.Add(info);
                GameObject model = ModelFromInfo(info);
                modelObjList.Add(model);
            }
        }
    }