Null reference exceptions on first access

More
3 years 2 months ago - 3 years 2 months ago #1458 by zmeinaz
I just updated my game and I am getting null reference exceptions when i first access I2.Loc.LocalizationManager.CurrentLanguage. This is in the start function of a script on my main menu. Any ideas what could cause that? I originally had it setup to update from google drive weekly. I recently changed it to daily, when I started noticing this issue. Does the reference become unavailable during an update from google drive?

My Script
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class UIManager_Language : MonoBehaviour {

	public GameObject LanguageMenu;
	public GameObject EnglishButton;
	public GameObject GermanButton;
	public GameObject ItalianButton;


	// Use this for initialization
	void Start () {
		SetLanguageButton();
	}
	
	// Update is called once per frame
	void Update () {
//		SetLanguageButton();
	}

	public void ShowLanguageMenu()
	{
		LanguageMenu.SetActive(true);
	}

	public void HideLanguageMenu()
	{
		SetLanguageButton();
		LanguageMenu.SetActive(false);
	}

	void SetLanguageButton()
	{
		Debug.Log("LANG: " + I2.Loc.LocalizationManager.CurrentLanguage);
		if (I2.Loc.LocalizationManager.CurrentLanguage.Equals("English"))
		{
			EnglishButton.SetActive(true);
			GermanButton.SetActive(false);
			ItalianButton.SetActive(false);
		}
		else if (I2.Loc.LocalizationManager.CurrentLanguage.Equals("German"))
		{
			EnglishButton.SetActive(false);
			GermanButton.SetActive(true);
			ItalianButton.SetActive(false);
		}
		else if (I2.Loc.LocalizationManager.CurrentLanguage.Equals("Italian"))
		{
			EnglishButton.SetActive(false);
			GermanButton.SetActive(false);
			ItalianButton.SetActive(true);
		}
	}
}

The Error:
I/Unity ( 9923):
I/Unity ( 9923): LANG:
I/Unity ( 9923): UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
I/Unity ( 9923): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
I/Unity ( 9923): UnityEngine.Logger:Log(LogType, Object)
I/Unity ( 9923): UnityEngine.Debug:Log(Object)
I/Unity ( 9923): UIManager_Language:SetLanguageButton() (at /Users/jeremyhenderson/Development/Unity/Mars Miner 2/Assets/myScripts/UIManager_Language.cs:36)
I/Unity ( 9923): UIManager_Language:Start() (at /Users/jeremyhenderson/Development/Unity/Mars Miner 2/Assets/myScripts/UIManager_Language.cs:15)
Last edit: 3 years 2 months ago by zmeinaz.

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #1459 by Frank
Hi,
Sorry for the delay in answering back. Was a bit sick yesterday so i couldn't look into this issue.

Did you updated your game to the latest AssetStore version (2.6.5f5) or to the latest Beta version (2.6.6a3)?
There has been lot of changes in these last versions related to the way the Google Live Synchronization and especially regarding how it keeps the downloaded data in the PlayerPrefs cache.

If you are seeing problems in 2.6.5f5, can you please, update to 2.6.6a3. I'm hoping the new changes fixes what you are seeing as I rewrote lot of it.
If instead, is version 2.6.6a3 the one giving you issues, can you please let me know what unity version are you using? Does this problem happens only in the Android device, or only in the editor.
Did you tried clearing the PlayerPrefs one last time and then update your game (version 2.6.6a3 fixes the issue with the cache, but you may have to do a final clear of the PlayerPrefs to delete any old key)

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #1460 by zmeinaz
I'm not sure what version I shipped the game with, but I recently updated to 2.6.5f5 (latest Asset Store version) and I have users complaining of crashes when the game starts. I was only able to duplicate it a few times and traced it down to the null reference exception when accessing CurrentLanguage. Erasing and reinstalling the game seems to fix it for me, but I need a solution for my players that doesn't involve uninstalling and reinstalling.

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #1461 by Frank

Erasing and reinstalling the game seems to fix it for me


Yes, that was the issue I fixed in 2.6.6a3.
If you update to 2.6.6a3 and release and update, the plugin will download the latest data into new PlayerPrefs keys and handle them better (not redownloading when there hasn't been any change).

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #1462 by zmeinaz
2.6.6a3 appears to fix the issue.

Thanks!

Please Log in or Create an account to join the conversation.

Time to create page: 0.139 seconds
Template by JoomlaShine