private void Awake() { if (!File.Exists(Application.persistentDataPath + "/AuthenticationData.authentication")) { loginMainPanel.SetActive(true); } else { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/AuthenticationData.authentication"; FileStream stream = new FileStream(path, FileMode.Open); PlayerAuthenticationData playerAuthenticationData = formatter.Deserialize(stream) as PlayerAuthenticationData; stream.Close(); PlayFabClientAPI.LoginWithPlayFab(new LoginWithPlayFabRequest { Username = playerAuthenticationData.userName, Password = playerAuthenticationData.password }, result => { SessionTicket = result.SessionTicket; id = result.EntityToken.Entity.Id; }, error => { Debug.Log(error.GenerateErrorReport()); }); } }
public void RememberUser(string userName, string password) { PlayerAuthenticationData playerAuthenticationData = new PlayerAuthenticationData(userName, password); BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/AuthenticationData.authentication"; FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, playerAuthenticationData); stream.Close(); }