NGUI Fonts

More
3 years 4 months ago #1295 by neuro
NGUI Fonts was created by neuro
Hi, I am using NGUI font's that I have created in it's own prefab/atlas and everything works fine when switching to Spanish and back to English.
But for Chinese and others I am using the Unity Ariel Unicode font.

I have set up a secondary term, with the font names, in text, for NGUI and fonts for Ariel. It switches fine between the languages, but when I go to say Chinese and then back to English, it doesn't load the NGUI font I was using, it stays with the Ariel font, when I need it to switch back to the NGUI font prefab.

Do you know why this would be happening and where in the code is this done so I can look at it?

using version 2.6.4 b2.

Thanks

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

More
3 years 3 months ago #1297 by Frank
Replied by Frank on topic NGUI Fonts
Hi,

Is that the only font that is not switching, or is there no fonts switching for you.

Is it that the font is not switching (you can verify it in the editor inspector by seeing if the label.font is changing) when switching languages?
Or is it that the label is not updating after the font is changed? (e.g. font changes, but the material and geometry is kept as it was)

As soon as I get back I will double check the NGUI examples just to be sure is all working properly.


Nonetheless, there can be some situations where the font fails to load:
To load the new font, the plugin calls GetSecondaryTranslatedObj to get the font specified as the SecondaryTerm. That font can be stored in different places:
If is in a Resource folder, then its loaded from there using the SecondaryTerm as the path. If is not in a Resource folder, then it has to be referenced in the LanguageSource or the Localize Component (there is a tab named "Assets" in the Language Source and a section at the end of the Localize component inspector as well). The plugin uses the SecondaryTerm to fetch for any referenced asset in the Localize component, if none is found, then it fetches for the assets in the language source, and falls back to searching in the Resource folder if none is found.

Therefore, the most common issue could be that the font is not in a Resources folder and is not Referenced in the LanguageSource (plugin will normally automatically add fonts to the referenced assets, but if they were reimported, changed, that can fail)

The code that changes the font for NGUI is at:

Assets/I2/Localization/Scripts/Targets/LocalizeNGUI.cs
public void DoLocalize_UILabel(string MainTranslation, string SecondaryTranslation)
		{
			//--[ Localize Font Object ]----------
			Font newFont = GetSecondaryTranslatedObj<Font>(ref MainTranslation, ref SecondaryTranslation);
			if (newFont!=null) 
			{
				if (newFont != mTarget_UILabel.ambigiousFont)
					mTarget_UILabel.ambigiousFont = newFont;
			}
			else
			{
				UIFont newUIFont = GetSecondaryTranslatedObj<UIFont>(ref MainTranslation, ref SecondaryTranslation);
				if (newUIFont!=null && mTarget_UILabel.ambigiousFont != newUIFont)
					mTarget_UILabel.ambigiousFont = newUIFont;
			}

Hope that helps, nonetheless, I will double check as soon as I get back home!

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 3 months ago - 3 years 3 months ago #1298 by neuro
Replied by neuro on topic NGUI Fonts
I looked and the prefab NGUI font is attached in the assets tab.
When I print out the translation and secondary translation in that function in LocalizeNGUI.cs it is printing out the proper font:

public void DoLocalize_UILabel(string MainTranslation, string SecondaryTranslation)
{
//--[ Localize Font Object ]
Font newFont = GetSecondaryTranslatedObj<Font>(ref MainTranslation, ref SecondaryTranslation);
Debug.Log("***** newFont: (" + newFont + "), MainTranslation: " + MainTranslation + ", SecondaryTranslation: " + SecondaryTranslation);
if (newFont!=null)
{

if (newFont != mTarget_UILabel.ambigiousFont)
mTarget_UILabel.ambigiousFont = newFont;
}
else
{
UIFont newUIFont = GetSecondaryTranslatedObj<UIFont>(ref MainTranslation, ref SecondaryTranslation);
Debug.Log("***** newFont is NULL: " + newUIFont + ", mTarget_UILabel.ambigiousFont: " + mTarget_UILabel.ambigiousFont);

if (newUIFont!=null && mTarget_UILabel.ambigiousFont != newUIFont)
mTarget_UILabel.ambigiousFont = newUIFont;
}
...

***** newFont: (), MainTranslation: English, SecondaryTranslation: GrilledCheese100
***** newFont is NULL: , mTarget_UILabel.ambigiousFont: GrilledCheese100 (UIFont)

But it doesn't seem to be updating it for some reason.

Another Example:
Switching to Chinese:
***** newFont: (), MainTranslation: Options, SecondaryTranslation: GrilledCheese100
***** newFont is NULL: , mTarget_UILabel.ambigiousFont: arial-unicode-ms (UnityEngine.Font)

Then switching Back to english:
***** newFont: (), MainTranslation: 大师, SecondaryTranslation: arial-unicode-ms
***** newFont is NULL: , mTarget_UILabel.ambigiousFont: GrilledCheese100 (UIFont)
Last edit: 3 years 3 months ago by neuro.

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

More
3 years 3 months ago #1299 by Frank
Replied by Frank on topic NGUI Fonts
Hi,
Are you still having this issue? I have been trying to reproduce it but haven't been able.

Just to be sure, I modified the NGUI and TextMeshPro example scenes to show changing fonts based on the language.
Could you please test it and check if your setup is similar to the one I'm using?

The changes were included in 2.6.5 a1 which can be downloaded from the beta folder.
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
3 years 3 months ago #1305 by neuro
Replied by neuro on topic NGUI Fonts
Still having the same issue, I will try the new beta stuff and look into it a bit more. Luckily I don't need to localize it in Asian or Russian yet.
Thanks

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

Time to create page: 0.165 seconds
Template by JoomlaShine