Use JsonUtility in unity to write objects to json files
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;
using System;
/// <summary>
/// 数据存储类,存放从外部读取的json数据---可以用结构体,这样占用会更小
/// </summary>
public class DataSave
{
public string name;
public string version;
public string date;
public List<string> max_List = new List<string>();
public List<main_list> main_List = new List<main_list>();
}
[Serializable]
public class main_list
{
public int id;
public string name;
public List<sub_list> sub_List = new List<sub_list>();
}
[Serializable]
public class sub_list
{
public int id;
public string name;
public List<process_list> process_List = new List<process_list>();
}
[Serializable]
public class process_list
{
public int id;
public string name;
public string model_name {
get; set; }//目前用不上
//public int animation_type { get; set; }//目前用不上
}
1. The [Serializable] above needs to be added, otherwise the data cannot be read.
2. The public int id; attribute should not be written as public int id { get; set; }, otherwise the data in the object will not be read.
3.