public static void saveFile(playerOne player) { BinaryFormatter formatter = new BinaryFormatter(); string savePath = Application.persistentDataPath + "/playerFILE.txt"; FileStream stream = new FileStream(savePath, FileMode.Create); playerFile playerData = new playerFile(player); formatter.Serialize(stream, playerData); stream.Close(); }
public void onSubmitClicked() { //Play sound buttonAudioSource.PlayOneShot(buttonAudioClip); copyUserName(); nameWindowTransition.SetTrigger("CLOSEname"); StartCoroutine(closeNameWindow()); saveSystemOne.saveFile(this); playerFile data = saveSystemOne.loadFile(); output.GetComponent <Text>().text = "hi" + (data.userName) + "!"; }
// Start is called before the first frame update void Start() { nameWindow.SetActive(false); nameDisp.SetActive(false); if (saveSystemOne.loadFile() == null) { nameWindow.SetActive(true); } else { playerFile data = saveSystemOne.loadFile(); output.GetComponent <Text>().text = "hi " + (data.userName); nameDisp.SetActive(true); } }
public static playerFile loadFile() { string savePath = Application.persistentDataPath + "/playerFILE.txt"; if (File.Exists(savePath)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(savePath, FileMode.Open); playerFile playerData = formatter.Deserialize(stream) as playerFile; stream.Close(); return(playerData); } else { Debug.LogError("FILE NOT FOUND AT " + savePath); return(null); } }
// Start is called before the first frame update void Start() { playerFile data = saveSystemOne.loadFile(); welcomeObject.GetComponent <Text>().text = (data.userName); }