Save and Load Data using "Player Prefs" Unity easy tutorial
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";
}
}