// Helper Functions to convert models to and from JSON public JObject Models2JSON() { ModelList modelList = new ModelList(); modelList.models = new ModelInfo[ModelInfoList.Count]; for (int i = 0; i < ModelInfoList.Count; i++) { modelList.models[i] = ModelInfoList[i]; } return(JObject.FromObject(modelList)); }
public void LoadModelsFromJSON(JToken mapMetadata) { ClearModels(); if (mapMetadata is JObject && mapMetadata["modelList"] is JObject) { ModelList modelList = mapMetadata["modelList"].ToObject <ModelList>(); if (modelList.models == null) { Debug.Log("no models added"); return; } foreach (var modelInfo in modelList.models) { AddModel(modelInfo); } } }