Created
July 4, 2016 09:36
-
-
Save zhenlinyang/a5a171acfdb21557c9fb8a4a265bf5a9 to your computer and use it in GitHub Desktop.
LitJson Sample for Unity3D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Param GetParam(string jsonPath) | |
{ | |
UnityEngine.Object asset = Resources.Load(jsonPath); | |
TextAsset textAsset = (TextAsset)asset; | |
string json = textAsset.text; | |
JsonReader jsonReader = new JsonReader(json); | |
JsonData jsonData = JsonMapper.ToObject(jsonReader); | |
Param param = new Param(); | |
param.Mode = (Mode)(int)jsonData["Mode"]; | |
param.Id = (int)jsonData["Id"]; | |
return param; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment