- Home /
[Problem] Use Playerpref.GetInt in other thread
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?
Your answer
Follow this Question
Related Questions
[Problem] Use Playerpref.GetInt in other thread 0 Answers
[Admob + PlayerPrefs] => TrySetInt can only be called from the main thread 2 Answers
How do I call a function in a different CPU core? 2 Answers
Persistent Simple Score 1 Answer
Best Practice for Multithreading Procedural Terrain Generation? 1 Answer