创造你的世界
数据存储
PlayerPrefs - 将数据保存到设备
1分
提供将玩家保存到他们连接的设备的能力。 如果您删除应用程序或更改设备,数据将不会被保留。 它支持与unity中的playerprefs相同的使用方式,存储容量限制为10kb。 ▼ 使用保存和加载功能检查播放次数的示例代码 import { zepetoscriptbehaviour } from 'zepeto script'; import { playerprefs } from 'unityengine'; export default class clientsaveload extends zepetoscriptbehaviour { private playcntkey string = 'keyname'; start() { if (playerprefs haskey(this playcntkey)) { playerprefs setint(this playcntkey, playerprefs getint(this playcntkey) + 1); console log(`playcnt ${ playerprefs getint(this playcntkey) }`); } else { playerprefs setint(this playcntkey, 1); console log('playcnt 1'); } } } 📘 查看unity playerprefs信息 https //docs unity3d com/scriptreference/playerprefs html https //docs unity3d com/scriptreference/playerprefs html