Save and Load Data using "Player Prefs" Unity easy tutorial

Subscribers:
1,110
Published on ● Video Link: https://www.youtube.com/watch?v=zyIS3hVHlg8



Category:
Tutorial
Duration: 3:22
82 views
9


Code :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerPrefsManager : MonoBehaviour
{
public string myKey = "StringKey";
public InputField inputField;

// Start is called before the first frame update
void Start()
{

}


public void SaveData()
{

PlayerPrefs.SetString(myKey,inputField.text);

// PlayerPrefs.SetInt(string key,int value);
// PlayerPrefs.SetFloat(string key,float value);


}

public void LoadData()
{
if (PlayerPrefs.HasKey(myKey))
{
inputField.text = PlayerPrefs.GetString(myKey);
// int value=PlayerPrefs.GetInt(string key);
// float value=PlayerPrefs.GetFloat(string key);
}

else inputField.text = "No data available";
}

}







Tags:
unity
unity3d
unity2d
learn unity
unity tutorials
player prefs in unity
unity player prefs
save data in unity
save and load data in unity
save and retrieve data in unity
save and load data using player prefs in unity
save and retrieve data using player prefs in unity