public void createAssetFromJSON(SimpleJSON.JSONNode doc)
{
Debug.Log("Create From JSON: " + doc.ToString());
try {
string type = doc[S.SA_TYPE].Value;
Vector3 position = new Vector3(float.Parse(doc[S.SA_POSITION]["x"].Value), float.Parse(doc[S.SA_POSITION]["y"].Value), float.Parse(doc[S.SA_POSITION]["z"].Value));
GameObject go = (GameObject)Instantiate(Resources.Load <GameObject>("AssetsLibrary/" + type), position, transform.rotation);
if (go.GetComponent <SyncedAsset>() == null)
{
Debug.LogError("Prefab missing Synched Asset");
}
else
{
go.GetComponent <SyncedAsset>().UpdateWithJSON(doc.ToString());
}
if (!Enum.IsDefined(typeof(AssetType), type))
{
Debug.Log("Type from JSON is not an AssetType");
AddToTree(go, (AssetType)Enum.Parse(typeof(AssetType), "Other"));
}
else
{
AddToTree(go, (AssetType)Enum.Parse(typeof(AssetType), type));
}
}
catch (Exception e)
{
Debug.Log(e.ToString());
}
}