- Home /
PlayerPrefs - Error in webplayer
Hi all,
I am trying to store some data using PlayerPrefs, in order to be used in the following runnings of the app. Well, if I use PC standalone in windows, it works perfectly. Thus, The first time I run the application, Playerprefs stores the data; and the followings the stored data are loaded perfectly.
The problem is that, when I use the webplayer for doing the same. It seems like the data are stored correctly, but Playerprefs does not load the data as expected. The code is the following (both standalone windows and webplayer):
Code for storing the data:
//Stores int
int n = 10;
PlayerPrefs.SetInt("selected_num",n);
//Stores two strings
string cc = "10-20-30-40";
PlayerPrefs.SetString("selected_for_classification",cc);
string dd = "4-66-3;5-6-7"
PlayerPrefs.SetString("selected_for_distances",dd);
Code for reading the data:
//We read the stored information
int n_readed = PlayerPrefs.GetInt("selected_num");
string classif = PlayerPrefs.GetString("selected_for_classification");
string distances = PlayerPrefs.GetString("selected_for_distances");
The error in webplayer is like it does not read well the stored data. Do you know what is happening? Please, I need help :).
Thank you very much in advance
The webplayer has a 1$$anonymous$$B limit on the data. You'd usually get an error when storing, though. Are you calling PlayerPref.Save
?
No, I'm not calling PlayerPref.Save... is it necessary? When should I call it? At the end of the code?
I have to say that, I have two differents webplayer apps in a public dropbox folder (thus, two different url's).
First, the user runs the app1...it creates several random numbers and stores these numbers by using Playerprefs. Once the first app is finished and closed...the user runs the app2 (different url, but same PC) and this app2 attempts to read these previously stored values (by app1) in order to use them during the running...
Is my code correct for achieving this aim?
Best,
Answer by Seizure · Sep 23, 2013 at 03:23 PM
That will not work 7toni7. PlayerPref's are based on each individual URL, you can not access them like that, what you'll need is a server side database that each of the different games talk to if you want to provide data across the platforms.
Thank you very much Seizure. Could you provide me further information about how to achieve this? I'm a little bit confused...
Best Antonio