PlayerPrefs is a straightforward way to save small amounts of data in Unity. Here's an example of how to use PlayerPrefs to save and edit a string value:
// Load the saved data file = File.Open(Application.persistentDataPath + "/playerdata.dat", FileMode.Open); PlayerData loadedData = (PlayerData)formatter.Deserialize(file); file.Close();
using UnityEngine;
// Edit the saved data data.username = "JaneDoe"; data.score = 200;
Unity Save Edit -
PlayerPrefs is a straightforward way to save small amounts of data in Unity. Here's an example of how to use PlayerPrefs to save and edit a string value:
// Load the saved data file = File.Open(Application.persistentDataPath + "/playerdata.dat", FileMode.Open); PlayerData loadedData = (PlayerData)formatter.Deserialize(file); file.Close();
using UnityEngine;
// Edit the saved data data.username = "JaneDoe"; data.score = 200;