Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [System.Serializable]
- public class Data {
- public int hp = 10;
- public int mana = 20;
- public float exp = 2.345f;
- }
- [System.Serializable]
- public class Cont {
- public string name = "container";
- public Data data1 = new Data();
- public Data data2 = new Data();
- }
- public class TTT : MonoBehaviour {
- public Cont container;
- [Multiline(5)]
- public string json;
- public string GetJson(Cont _cont) {
- string s = JsonUtility.ToJson(_cont);
- return s;
- }
- public Cont GetData(string _json) {
- return JsonUtility.FromJson<Cont>(_json);
- }
- public void ToJson() {
- json = GetJson(container);
- }
- public void ToObject() {
- container = JsonUtility.FromJson<Cont>(json);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement