// Use this for initialization void Start() { AuthURL = APIUrl + "/auth"; SaveURL = APIUrl + "/save"; CheckAuthURL = AuthURL + "/check/"; LoadingSlider = LoadingScreen.GetComponentInChildren <Slider>(); LoginNav.Add(LoginUser); LoginNav.Add(LoginPass); UserPrefsData localInfo = GetUserData(); if (localInfo != null) { RegisterComplete data = new RegisterComplete(); data.id = localInfo.id; data.token = localInfo.token; data.username = localInfo.username; if (data.token != null && data.token.Length > 0) { StartCoroutine(CheckAuth(data, true)); } } }
public UserPrefsData GetUserData() { UserPrefsData localInfo = new UserPrefsData(); localInfo.id = PlayerPrefs.GetInt("user_id", -1); if (localInfo.id == -1) { return(null); } localInfo.username = PlayerPrefs.GetString("user_username"); localInfo.token = PlayerPrefs.GetString("user_token"); localInfo.tokenExpireDate = PlayerPrefs.GetString("user_token_expireDate"); return(localInfo); }
private static void SavePrefs(string fileName) { BinaryFormatter bf = new BinaryFormatter(); //create a binary formart FileStream file = File.Create(Application.persistentDataPath + "/" + fileName); //create a file called SavaData.dat UserPrefsData data = new UserPrefsData(); // Create a data object using a serializable class //-------- pass the Prefs values to data ------------- data.wantToMeet = new List <AppManeger.Gender>(); data.wantAge = new int[2]; data.wantToMeet = AppManeger.instance.wantToMeet; data.wantAge = AppManeger.instance.wantAge; data.isSmoke = AppManeger.instance.isSmoke; data.yourHabit = AppManeger.instance.yourHabit; //---------------------------------------------------- bf.Serialize(file, data); //write data on file file.Close(); Debug.Log("Prefs Saved"); }
private static void LoadPrefs(string fileName) { if (File.Exists(Application.persistentDataPath + "/" + fileName)) { BinaryFormatter bf = new BinaryFormatter(); //create a binary formart FileStream file = File.Open(Application.persistentDataPath + "/" + fileName, FileMode.Open); //open the file called SavaData.dat UserPrefsData data = (UserPrefsData)bf.Deserialize(file); //Gets the data and put on the data variable file.Close(); //----------- Store data into Prefs vars -------------- AppManeger.instance.wantToMeet = data.wantToMeet; AppManeger.instance.wantAge = data.wantAge; AppManeger.instance.isSmoke = data.isSmoke; AppManeger.instance.yourHabit = data.yourHabit; //----------------------------------------------------- Debug.Log("Prefs data Load"); } else { Debug.Log("Prefs save data doesn't exit"); } }
public UserPrefsData Validate(UserPrefsData userPrefsData) { CheckNull(userPrefsData); return(userPrefsData); }