Hi! i'm having a problem using playerpref.getint in other thread created in the game. i have been trying ways of us playpref.getint in other thread for more than 8 hours.
i'm doing this:
Thread t = new Thread(ScoresOnline);
t.Start();
and this:
void ScoresOnline(){
int bestSctore = PlayerPrefs.GetInt("Score")
scoreBoard.SaveScore(bestSctore);
(...)
}
Im getting this error:
GetInt can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
Please anything that could help, would be great, i have already tried a lot of things, but not the right one.
So, can you help me?
↧