---
title: PlayerPrefs - デバイスにデータを保存
slug: world-sdk-guide-ja/playerprefs
docTags: 
createdAt: 2024-09-02T08:34:13.134Z
---

接続しているデバイスにプレイヤーを保存する機能を提供します。
クライアントZEPETOスクリプトから呼び出すことができ、アプリを削除したりデバイスを変更した場合、データは保持されません。

UnityのPlayerPrefsと同様に使用をサポートしており、ストレージ容量は10KBに制限されています。



▼ Save & Load機能を使用してプレイ回数を確認するための例コード

```typescript
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');
        }
    }
}
```

:::hint{type="info"}
**📘 Unity PlayerPrefs情報を見る**
[https://docs.unity3d.com/ScriptReference/PlayerPrefs.html](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html)
:::

