当前位置:网站首页>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();
边栏推荐
- Memory learning book reference
- ES6解构赋值
- A summary of global variables and typedef
- Large end storage and small end storage
- [Latex] 插入圖片
- Sliding window summary of TCP connections
- Go JWT learning summary
- September 3, 2021 visual notes
- [learn FPGA programming from scratch -21]: Advanced - Architecture - VerilogHDL coding specification
- This of phaser3 add. add. image
猜你喜欢
Traversal of binary tree - first order traversal, middle order traversal, and second order traversal
Realization of flip animation
Argparse command line passes list type parameter
DFS and BFS notes (II): depth first search (implemented in C language)
Install pycharm process
Summary of various installation methods of Lab View
Leetcode question brushing 04 string
September 3, 2021 visual notes
【斯坦福計網CS144項目】Lab1: StreamReassembler
Leetcode question brushing 06 bit operation
随机推荐
Method of cleaning C disk
Go JWT learning summary
Golang learning essay
Project training (XVII) -- personal work summary
Idea installation tutorial
Golang context (context summary)
Alexnet实现Caltech101数据集图像分类(pytorch实现)
How many times does the constructor execute?
Loss calculation in pytorch
Crypto JS reports uglifyjs error
Memory learning book reference
Transaction characteristics and isolation levels
Introduction to convolutional neural network
Anims of phaser3
September 3, 2021 visual notes
Work and life
Phaser3 load
Leetcode-17- letter combination of phone number (medium)
[WSL2]限制WSL2可访问的硬件资源(CPU/内存)
MySQL performance optimization