当前位置:网站首页>Unity JsonUtility 无法序列化List
Unity JsonUtility 无法序列化List
2022-06-13 01:27:00 【末零】
1、现象
JsonUtility.ToJson序列化后为{}
2、原因
虽然Unity提供了JsonUtility,但List不能被直接序列化存储
3、解决方案
自定义类
3.1 添加代码
[Serializable]
public class Serialization<T>
{
[SerializeField]
List<T> target;
public List<T> ToList() {
return target; }
public Serialization(List<T> target)
{
this.target = target;
}
}
3.2 使用
Ranking 为要序列化的类
string result = JsonUtility.ToJson(new Serialization<Ranking>(rankingList));
return JsonUtility.FromJson<Serialization<Ranking>>(list).ToList();
边栏推荐
- Tangent and tangent plane
- leetode. 242. valid Letter heteronyms
- Method of cleaning C disk
- My crawler learning notes
- Leetcode-13- Roman numeral to integer (simple)
- Tweens of phaser3
- Temporary objects and compilation optimization
- Sonarqube local installation
- MySQL performance optimization
- Mysql database listening -canal
猜你喜欢

Plusieurs catégories de tests logiciels sont claires à première vue

Argparse command line passes list type parameter

Leetcode question brushing 07 double pointer

5G工业网关在煤矿行业的应用优势

C language implementation of the classic eight queens problem

Alexnet implements image classification of caltech101 dataset (pytorch Implementation)

Minimum score of one question per day

Memory learning book reference

Introduction to common activation functions

MySQL related summary
随机推荐
Leetcode-14- longest common prefix (simple)
[projet cs144 de Stanford Computing Network] lab1: Stream reassembler
Pytorch's leafnode understanding
Leetcode question brushing 04 string
Wikipedia API User Guide
Docker install MySQL
Leetcode-9-palindromes (simple)
#pragma comment(lib,“urlmon.lib“)
Logical operation bit operation
[Stanford Jiwang cs144 project] lab1: streamreassembler
The storage structure of a tree can adopt the parent representation, that is, the parent pointer array representation. Try to give the corresponding class definition. Each tree node contains two membe
Install pycharm process
Stack stack LIFO
Tkinter library installation
Calculate sentence confusion ppl using Bert and gpt-2
[Andoid][踩坑]CTS 11_r3开始出现的testBootClassPathAndSystemServerClasspath_nonDuplicateClasses FAIL问题分析
Leetcode-16- sum of the nearest three numbers (medium)
Tangent and tangent plane
Alexnet implements image classification of caltech101 dataset (pytorch Implementation)
Characteristics of transactions -- atomicity (implementation principle)