---
title: PlayerPrefs - การบันทึกข้อมูลลงบนอุปกรณ์
slug: world-sdk-guide-th/playerprefs
docTags: 
createdAt: 2024-09-02T08:34:13.134Z
---

ให้ความสามารถในการบันทึกผู้เล่นลงในอุปกรณ์ที่พวกเขากำลังเชื่อมต่ออยู่
ข้อมูลจะไม่ถูกเก็บรักษาหากคุณลบแอปหรือเปลี่ยนอุปกรณ์.

รองรับการใช้งานในลักษณะเดียวกับ PlayerPrefs ใน Unity และความจุในการจัดเก็บจำกัดอยู่ที่ 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"}
**📘 ดูข้อมูล PlayerPrefs ของ Unity**
[https://docs.unity3d.com/ScriptReference/PlayerPrefs.html](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html)
:::

