当前位置:网站首页>Unity jsonutility failed to serialize list
Unity jsonutility failed to serialize list
2022-06-13 01:31:00 【Last zero】
1、 The phenomenon
JsonUtility.ToJson Serialized as {}
2、 reason
although Unity Provides JsonUtility, but List Cannot be serialized and stored directly
3、 Solution
Custom class
3.1 Add code
[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 Use
Ranking For the class to serialize
string result = JsonUtility.ToJson(new Serialization<Ranking>(rankingList));
return JsonUtility.FromJson<Serialization<Ranking>>(list).ToList();
边栏推荐
- Leetcode-17- letter combination of phone number (medium)
- Tweens of phaser3
- Crypto JS reports uglifyjs error
- Wangdao machine test - Chapter 6 - maximum common divisor GCD and minimum common multiple LCM
- What kind of experience is it to be a software test engineer in a state-owned enterprise: every day is like a war
- 【斯坦福計網CS144項目】Lab1: StreamReassembler
- Leetcode find duplicates
- MySQL ---- where后使用字段别名
- Happy string
- FSOs forest simulation optimization model learning notes
猜你喜欢
![[leetcode] valid phone number Bash](/img/f8/cecb74f9d8f7c589e62e3a9a874f82.jpg)
[leetcode] valid phone number Bash

4K sea bottom and water surface fabrication method and ocean bump displacement texture Download

Introduction to convolutional neural network
![[projet cs144 de Stanford Computing Network] lab1: Stream reassembler](/img/7b/fad18b68a6ee30d1dec4dad6273b98.png)
[projet cs144 de Stanford Computing Network] lab1: Stream reassembler

Several categories of software testing are clear at a glance

Install pycharm process

Application advantages of 5g industrial gateway in coal industry

Status of the thread

leetcode 142. Circular linked list II

Page optimization - Notes
随机推荐
Temporary objects and compilation optimization
Exercise 5.14 input n strings, arrange them in alphabetical order and output them.
np. Understanding of axis in concatenate
A summary of global variables and typedef
My crawler learning notes
【MathType】利用MathType输出LaTex样式的公式
Method of cleaning C disk
Status of the thread
Leetcode question brushing 03 stack
Stmarl: a spatio temporal multi agentreinforcement learning approach for cooperative traffic
Unity JsonUtility 无法序列化List
MySQL performance analysis - explain
leetcode 206. Reverse linked list
QT color extraction
Work and life
【斯坦福計網CS144項目】Lab1: StreamReassembler
Downloading wiki corpus and aligning with multilingual wikis
Leetcode-9-palindromes (simple)
Vector|hdu-4841 round table questions
leetode. 242. valid Letter heteronyms