using UnityEngine; using System.Collections; using Newtonsoft.Json.Linq; using System.Collections.Generic; using Newtonsoft.Json; using System.Linq; public class TestSetting : MonoBehaviour { // Use this for initialization void Start() { } // Update is called once per frame void Update() { } void OnGUI() { //if (GUI.Button(new Rect(10, 10, 200, 100), "testIsReset")) //{ // if (GameCfg.PlayerSettings["lala"]["a1"] == null) // { // } //} //if (GUI.Button(new Rect(10, 110, 200, 100), "testSave")) //{ //} if (GUI.Button(new Rect(10, 220, 200, 100), "testUpdate")) { //LocalSettings.DefaultUserName = "1"; GameCfg.SaveLocalSettings(); } //if (GUI.Button(new Rect(10, 330, 200, 100), "testRead")) //{ // string str = "{\"3\":123,body:456,list:{title:'abc',body:'what'}}"; // JObject jo = JObject.Parse(str); // if (jo.Property("3") == null || jo.Property("3").ToString() == "") // { // Debug.LogError("键值key不存在!"); // } // bool hasErr = jo.Properties().Any(p => p.Name == "err");//或是这样 // IEnumerable properties = jo.Properties(); // foreach (JProperty item in properties) // { // Debug.LogError(item.Name + ":" + item.Value); // } //} } }