I built my first game with Unity. I have tested it on an Android tablet and a Windows PC. I have the same problem on both platforms. After installing the game it never works on the initial launch, but every time after that it works smoothly without any faults.
Is this a problem with Unity personal edition or should I look at my code somewhere?
If it’s my code, please give me any suggestion where I should start to look.
Hi,
Many thanks for the replies.
It seems the problem is it’s not loading the player prefs when the game runs for the first time.
Obviously the first time the game runs there isn’t any data to load, so how to I get round that problem.
I have an void Awake script in another script but is doesnt seem to be checking this properly.
Please help / advise again.
private void Awake()
{
instance = this;
DontDestroyOnLoad (gameObject);
if (PlayerPrefs.HasKey ("CurrentSkin"))
{ // We had a previous session
currentSkinIndex = PlayerPrefs.GetInt ("CurrentSkin");
currency = PlayerPrefs.GetInt ("Currency");
skinAvailability = PlayerPrefs.GetInt ("SkinAvailability");
} else
{
Save();
}`