Null Reference Exception when accessing baked term

More
6 years 6 months ago - 6 years 6 months ago #3078 by koalitygame
This is a really weird issue that's been giving me trouble. Although it doesn't happen 100% of the time, always after the first install I will get a Null Reference Exception when trying to get translation for a baked term. It also always happens on the exact same term. It's troubling because the term is in the tutorial phase which could lead to a lot of players experiencing an issue at the start of the game and not being able to continue. The code is very simple:
instructions.text = I2.Loc.ScriptLocalization.KEEP_ATTACKING_TO_BUILD_MOMENTUM.ToUpper();
To test this, I used
Debug.Log(I2.Loc.ScriptLocalization.KEEP_ATTACKING_TO_BUILD_MOMENTUM.ToUpper());
at that specific point in the game which gave me this error message: NullReferenceException: Object reference not set to an instance of an object

It's not any different than the other hundreds of baked terms that I have in the game, so I'm really perplexed. Although I did add this term later than I did the others. I also noticed that it happens after the message "Done Google Sync". Any ideas of what could be causing the issue?

Edit: Setting Auto Update Frequency to 'Never' resolves the issue for the time being.
Last edit: 6 years 6 months ago by koalitygame.

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

More
6 years 6 months ago #3082 by Frank
Hi,
It looks like you have Google Live Synchronization enabled, but your spreadsheet is not up-to-date with the Editor.
In the latest version of I2 Localization there is a warning showed in the editor when thats the case, so I advice you to update to the latest version if you haven't.

The problem you are seeing is that the term KEEP_ATTACKING_TO_BUILD_MOMENTUM is in your I2Languages.prefab, but not in your Spreadsheet (or not with all the languages). Then, when you build your game and play it in the device, I2L checks the spreadsheet, and sees that it doesn't match what's in the LanguageSource, so I2L thinks that you have made changes, and therefore it downloads the spreadsheet and overrides your data (showing the "Done Google Sync").

At that point, if you ask for the term value, it returns null because that term doesn't exist in the downloaded Spreadsheet or it exists but doesn't have the language you have set.

The solution to this is: Either make sure your spreadsheet is always up-to-date before doing a build (do an Export to google before building), or Don't use Google Live Synchronization (set Update frequency to NEVER).

Hope that helps,
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
6 years 6 months ago #3083 by koalitygame
Great, thanks for the explanation Frank!

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

Time to create page: 0.197 seconds
Template by JoomlaShine