Secondary Term for Font on all Localize components

More
6 years 8 months ago #2373 by fiveamp
We are using a secondary term on Localize components to switch the font based on languages. And using Textmesh Pro to split our fonts into smaller atlases with characters used per language. Is there any easy way to force this secondary term to be on all localize components without the need to add it manually to each component?

I wrote a simple editor script to do this for us, but I still feel like there must be an easier more efficient way to accomplish this. Any thoughts?
[MenuItem("Tools/i2 - Add Font to Loc Components", false, 512)]
public static void AddFontToLocs()
{
	int locsFixed = 0;
	Localize[] locList = FindObjectsOfType<Localize>();
	foreach (Localize loc in locList)
	{
		if (string.IsNullOrEmpty(loc.SecondaryTerm)) {
			loc.SecondaryTerm = "UI_MAIN/DefaultFont";
			locsFixed++;
		}
	}
	string message;
	if (locList.Length < 1) {
		message = "No Localize Components Found in current Scene Hierarchy";
	}
	else {
		message = locList.Length.ToString() + " Localize's found. ";
		if (locsFixed > 0) {
			message += locsFixed.ToString() + " fixed with DefaultFont secondary term";
		}
	}
	Debug.Log(message);
}

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

More
6 years 8 months ago #2374 by Frank

Is there any easy way to force this secondary term to be on all localize components without the need to add it manually to each component?


Yes,
I2 Localization will try to detect which term should be used based on the context.
In the case of secondary terms it uses the name of the original font.

To setup this, just place your TMP label, and assign one of the fonts (e.g. "TMP_Arial")
Then, create a font with that EXACT name (e.g. "TMP_Arial"). and assign each of the per-language fonts to each of the translations (e.g. TMP_Arial_ch, TMP_Arial_ru, etc)


When the game runs, it will see that it doesn't have a secondary term, so it tries to infer it by getting the name of the font (TMP_Arial), it will see that there is a term named like that, so it will use it.

If you set this correctly, you will see the secondary term in the inspector automatically detecting the font term and showing it in a darker color so that you know it is an "inferred term".

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
The following user(s) said Thank You: fiveamp

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

More
6 years 8 months ago #2375 by fiveamp
Perfect!
Note, it looks like the naming restriction for the additional Font assets is not necessary. Only that the term itself is named after the main font so that the 'inferred' feature works. In the term we have a different asset resources & naming for each lang as the font assets do not derive from the same font.

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

More
6 years 8 months ago #2376 by fiveamp
Additional quick question:
If secondary terms are left empty, will they be inferred during runtime or do they need to be auto-inferred during edit mode which will set the secondary term.

example attached.
Attachments:

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

More
6 years 8 months ago #2378 by Frank
Empty terms will be inferred at runtime.
But if you open the localize inspector, and make a change in the term's popup, that inferred term will become a regular term. Unless you manually select the last popup option to make it <inferred> again.

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
The following user(s) said Thank You: fiveamp

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

More
6 years 8 months ago #2380 by fiveamp
Awesome, thanks!

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

Time to create page: 0.192 seconds
Template by JoomlaShine