u3d使用json存储本地数据

本文总结了在Unity3D中使用JSON进行本地数据存储的方法,包括自定义数据类、选择存储路径(避免在iOS上的限制,通常使用Application.persistentDataPath),以及如何读写JSON文件。特别强调在实际平台上务必使用Application.persistentDataPath来确保数据持久化。
摘要由CSDN通过智能技术生成

u3d使用json存储本地数据

本人在使用json遇到各种坑,现在总结一下,免得以后忘记

1. 首先得自定义一个类,*

这个类主要写明数据的类型

using System;
using System.Collections.Generic;

[Serializable]
public class LevelData
{
   
    public int score;   //得分
    public bool isLock;//是否解锁
    public int level;//当前关卡
    public int differences;//不同之处的数量
}`

2.然后选择存储的位置

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using LitJson;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值