Created
April 20, 2019 14:38
-
-
Save gkagm2/f28b6b8ab00f122f723495d1fede93f0 to your computer and use it in GitHub Desktop.
PlayerPrefs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; // need | |
public class csGameManager : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
private void OnGUI() | |
{ | |
if(GUI.Button(new Rect(30, 50, 180,30), " Set Value")) | |
{ | |
SetData(); | |
} | |
if (GUI.Button(new Rect(30, 100, 180, 30), "Get Value")) | |
{ | |
GetData(); | |
} | |
} | |
void SetData() | |
{ | |
// Key / Value | |
PlayerPrefs.SetInt("Score", 100); | |
PlayerPrefs.SetString("Name", "홍길동"); | |
} | |
void GetData() | |
{ | |
//Get Value by Key. | |
int myScore = PlayerPrefs.GetInt("Score"); | |
string myName = PlayerPrefs.GetString("Name", "N/A"); | |
if (EditorUtility.DisplayDialog("알림", "출력할 내용을 선택하세요.", "이름", "점수")) | |
{ | |
Debug.Log("Name: " + myName); | |
} | |
else | |
{ | |
Debug.Log("Score: " + myScore); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment