今天看到一个unity 自带的解析json的IPA,感觉比litjson好用很多,废话不多,上代码 using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using System.IO; [Serializable] public class MyClass { public int level; public float timeElapsed; public s
今天在些项目的时候,遇到一个坑,现在跟大家分享一下 我遇到的错误是MissingMethodException: Method not found: 'Default constructor not found...ctor() of bagItemJson'. 大概的意思就是说没有找到什么方法 下面我们来看看为什么会遇到这个问题 首先先写一个类 public class BagItem //一个类,用来表示背包里面的装备 { public string name; public int l
以前说到的,有很大的限制,只能解析简单的类,如果复杂的就会有问题,从老外哪里看到一片博客,是将类中的list 等复杂对象序列化, using UnityEngine; using System.Collections; using System.Collections.Generic; using System; // List<T> [Serializable] public class Serialization<T> { [SerializeField] List<
官网案例传送门 我这里不过是借花献佛,案例官网就有. using UnityEngine; using System.Collections; public class json : MonoBehaviour { public class JsonInfo { public int id; public string name; public int age; } void Start () { JsonInfo Info=new JsonInfo(); Info.id = ; Info.na
Introduction 简介In previous chapters, you saw some of the reasons to use dependency injection and learned how dependency injection differs from other approaches to decoupling your application. In this chapter you'll see how you can use the Unity depen