地址来源:
How to Read JSON Data in Unity (LitJSON)
-------------------------------------------------------------------ReadJson
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using LitJson;//*******************************************************
public class ReadJson : MonoBehaviour {
private string jsonstring;
private JsonData itemData;
// Use this for initialization
void Start () {
string filename = Application.dataPath + "/Resources/" + "Items.json";
//Debug.Log(Application.dataPath + "/Resources/"+"Items.js

本文档展示了如何在Unity项目中利用LitJSON库读取并解析JSON文件,特别是处理包含多个数据项(如玩家得分表)的数组。通过`File.ReadAllText`获取JSON字符串,然后使用`JsonMapper.ToObject`将JSON转换为`JsonData`对象,从而访问和打印JSON对象的特定元素。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



