- Home /
PlayerPref not working on linux / ubundu
Hello
I'm having an issues with the playerprefs in unity: they don't save when i quit the game and i launch it again. I'm doing smth like a texte editor but for personal and specific use.
public static void SaveTexts(){
if (ParagraphManager.ins.base2.isOn){
PlayerPrefs.SetString("oText", ins.PM.texts[0]);
PlayerPrefs.SetString("tText", ParagraphManager.ins.base2IF.text);
ins.PM.texts[1] = ins.PM.base2IF.text;
} else {
string[] texts = ins.ParagraphsToText();
if (texts[0] != "")
PlayerPrefs.SetString("oText", texts[0]);
if (texts[1] != "")
PlayerPrefs.SetString("tText", texts[1]);
ParagraphManager.ins.texts = PPManager.ins.ParagraphsToText();
}
PlayerPrefs.SetString("tTitle", ParagraphManager.ins.tTitle.text);
PlayerPrefs.SetString("oTitle", ParagraphManager.ins.oTitle.text);
PlayerPrefs.SetFloat("timeSelected", TimeManager.ins.timeSelected);
PlayerPrefs.Save();
}
That's the function to set the playerprefs. It's called when we click on a button, and every ten sec
public static void LoadTexts(){
if (!PlayerPrefs.HasKey("tText") || !PlayerPrefs.HasKey("oText") || !PlayerPrefs.HasKey("tTitle") || !PlayerPrefs.HasKey("oTitle"))
return;
ParagraphManager.DeleteParagraphs();
ins.PM.texts[0] = PlayerPrefs.GetString("oText");
ins.PM.texts[1] = PlayerPrefs.GetString("tText");
ins.TextToParagraphs(PlayerPrefs.GetString("oText"), PlayerPrefs.GetString("tText"));
}
Here is the loading function, basicaly juste some GetString. Called at the start of the "game" and when we click on a button.
I'm sure these two functions are caller (i have some kind of log system) and the playerspref seemed to be working as long as I don't close the game. In the editor it works perfectly fine but when i try to build it, it doesn't work.
When i start the game using terminal (on ubuntu) i got a line saying 'Unable to load player prefs':
The playerprefs keys are: tTitle, tText, oTitle, oText, timeSelected and autoSave.
I hope someone will be able to help me out. Thx for reading.
Your answer
Follow this Question
Related Questions
Location of player prefs in Linux 1 Answer
Player Prefs not Saving in Linux 1 Answer
Game crash on Ubuntu 2 Answers
What are the stand alone Linux player dependencies? 3 Answers