using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestPlayerPrefsMain : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//PlayerPrefs.SetInt("player_lv", 1);
bool hasKey = PlayerPrefs.HasKey("player_damage");
Debug.LogFormat("hasKey: {0}", hasKey);
float damage0 = PlayerPrefs.GetFloat("player_damage");
Debug.LogFormat("damage0: {0}", damage0);
//키가 없다면 기본값을 설정해서 얻고싶다
float damage1 = PlayerPrefs.GetFloat("player_damage", 1.5f);
Debug.LogFormat("damage1: {0}", damage1);
//int lv = PlayerPrefs.GetInt("player_lv");
//Debug.LogFormat("lv: {0}", lv);
PlayerPrefs.DeleteKey("player_lv");
}
// Update is called once per frame
void Update()
{
}
}
PlayerPrefs는 보안성이 좋지않다. [아무나 수정가능]
'유니티 심화' 카테고리의 다른 글
절대강좌 유니티 - 내비게이션 고급 기법, 동적장애물, 적 자연스러운 회전처리, Area Mask (0) | 2023.08.29 |
---|---|
절대강좌 유니티 - Raycast (0) | 2023.08.29 |
법선벡터 (0) | 2023.08.28 |
오브젝트 풀링 - 총알, 이펙트 (1) | 2023.08.28 |
절대강좌 유니티 - 오브젝트 풀링 (0) | 2023.08.28 |