Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

How do I acces GetInt out of the "main thread"

$
0
0
I get 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. #pragma strict guiText.fontSize=Screen.width/25; var highscore:int=PlayerPrefs.GetInt("highscore",0); function Update(){ PlayerPrefs.SetInt("highscore",highscore); guiText.text=highscore.ToString(); if(score>highscore){ highscore=score; } } I don't actually use "score" but I just wanted to show the code logic.

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>