Esempio n. 1
0
    public JObject LoadConfig(string configName)
    {
        UnityEngine.Object obj     = PrefabLoader.LoadPrefabSync("jsonconfig.u3dassetbundle", configName, true);
        string             json    = (obj as TextAsset).ToString();
        JObject            jsonObj = JObject.Parse(json);

        #region 遍历示例
        //Debug.Log(jsonObj["ItemList"].ToString());
        //foreach (var item in jsonObj)
        //{
        //    Debug.Log(item.Key);
        //    Debug.Log(item.Value);
        //    Debug.Log(item.Value[0]);
        //    Debug.Log(item.Value[1]);
        //    JArray array = item.Value as JArray; // 是数组([])才可以转换成JArray, 不是数组转换会返回Null
        //    foreach (var rowItem in array)
        //    {
        //        Debug.Log(rowItem);
        //        Debug.Log("Name" + ":" + rowItem["Name"]);
        //        Debug.Log("Id" + ":" + rowItem["Id"]);
        //        foreach (var colItem in rowItem)
        //        {
        //            Debug.Log(colItem.ToString());
        //        }
        //    }
        //}
        #endregion

        return(jsonObj);
    }