개발/Unity
Unity) JsonUtility class Parsing Problem
테샤르
2021. 3. 18. 17:48
JsonUtility class Parsing Problem
Unity에서 내장으로 JSON을 파싱 해주는 JsonUtility를 사용하다 보면
serialize/ deserialize 를 사용해서 JSON 형태로 변경이 가능하다.
List <Class> 형태로 변환하는 과정에서 데이터 변경이 안 되는 문제가 있는데
이때 해당 클래스도 [System.Serializable]으로 변경해야 된다.
public class ParsingClass
{
public List<ParsingInfo> list;
}
[System.Serializable]
public class ParsingInfo{
public string name;
}
Unity Doc : [링크]
Unity - Scripting API: JsonUtility.ToJson
Internally, this method uses the Unity serializer; therefore the object you pass in must be supported by the serializer: it must be a MonoBehaviour, ScriptableObject, or plain class/struct with the Serializable attribute applied. The types of fields that y
docs.unity3d.com
★☆☆☆☆
반응형