TestSetting.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEngine;
  2. using System.Collections;
  3. using Newtonsoft.Json.Linq;
  4. using System.Collections.Generic;
  5. using Newtonsoft.Json;
  6. using System.Linq;
  7. public class TestSetting : MonoBehaviour
  8. {
  9. // Use this for initialization
  10. void Start()
  11. {
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. }
  17. void OnGUI()
  18. {
  19. //if (GUI.Button(new Rect(10, 10, 200, 100), "testIsReset"))
  20. //{
  21. // if (GameCfg.PlayerSettings["lala"]["a1"] == null)
  22. // {
  23. // }
  24. //}
  25. //if (GUI.Button(new Rect(10, 110, 200, 100), "testSave"))
  26. //{
  27. //}
  28. if (GUI.Button(new Rect(10, 220, 200, 100), "testUpdate"))
  29. {
  30. //LocalSettings.DefaultUserName = "1";
  31. GameCfg.SaveLocalSettings();
  32. }
  33. //if (GUI.Button(new Rect(10, 330, 200, 100), "testRead"))
  34. //{
  35. // string str = "{\"3\":123,body:456,list:{title:'abc',body:'what'}}";
  36. // JObject jo = JObject.Parse(str);
  37. // if (jo.Property("3") == null || jo.Property("3").ToString() == "")
  38. // {
  39. // Debug.LogError("键值key不存在!");
  40. // }
  41. // bool hasErr = jo.Properties().Any(p => p.Name == "err");//或是这样
  42. // IEnumerable<JProperty> properties = jo.Properties();
  43. // foreach (JProperty item in properties)
  44. // {
  45. // Debug.LogError(item.Name + ":" + item.Value);
  46. // }
  47. //}
  48. }
  49. }