12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using LitJson;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using BestHTTP.JSON;
- public class tb_SensorRecordModel
- {
- public int ID { get; set; }
- public decimal Value1 { get; set; }
- }
- public class WorldPosToUIPos : MonoBehaviour
- {
- private void Awake()
- {
- Data_PlayerAttributes dataPA = JsonMapper.ToObject<Data_PlayerAttributes>(JsonRead("cel_Label"));
- Debug.Log(dataPA);
- }
- public string JsonRead(string name)
- {
- string json = "";
- TextAsset text = Resources.Load<TextAsset>("Jsons/" + name);
- json = text.text;
- if (string.IsNullOrEmpty(json)) return null;
- return json;
- }
- void Start()
- {
- MyCallLitJson();
- }
- private void MyCallLitJson()
- {
- JsonData hero1JD = new JsonData();
- hero1JD["name"] = "SuperMan";
- hero1JD["power"] = 90;
- JsonData hero2JD = new JsonData();
- hero2JD["name"] = "BatMan";
- hero2JD["power"] = 87;
- JsonData heroArray = new JsonData();
- heroArray.Add(hero1JD);
- heroArray.Add(hero2JD);
- JsonData herosJD = new JsonData();
- herosJD["heros"] = heroArray;
- string strJson = herosJD.ToJson();
- print(strJson);
- }
- }
|