HI,
Im facing a problem in doing Localicazion. I have different fonts.
1) English
2) Chiense
3) etc
For the time beign they are two but can increase.
Im using English Bitmap Font for English and other languages and dynamic font for Chinese.
I want to switch between these two fonts. I have done this many times with atlas but With fonts it creating a problem.
I have tried two methods
1) Load RefFont From resources and change it
2) Place RefFont In scene Get it and do action.
Problem with 1 is All the Lables pointing to the RefFont (placed in resources folder)dont get affected. What i mean is what ever i do from code nothing happens. but when in change the font in RefFont i.e drag drop chiense or english font they change in the game.
2) Now All the lables are pointing to the refFont Placed in the scene. Reffont(Embedded) WHen i switch the font all my lables show blank.
What actually Happens is When ever i execute my following code. The Font(GameObject) type is changed from Reference to Bitmap dont know why this happens. And i couldnt find any way to change font type.
IF i manually Change the fonts type to reference (in the hiererchy while game is running) and Assign it chinese or english it works not through code.
Heres the code
void SwitchFont(int lang)
{
if(!font)
// font = (Resources.Load("Fonts/RefFont") as GameObject).GetComponent<UIFont>();
font = GameObject.FindGameObjectWithTag ("RefFont").GetComponent<UIFont> ();
switch (lang)
{
case gLocale.LANG_ENGLISH:
font.replacement = Resources.Load("Fonts/English Font") as UIFont;
break;
case gLocale.LANG_CHINESE:
font.replacement = Resources.Load("Fonts/Chinese Font") as UIFont;
break;
case gLocale.LANG_FRENCH:
break;
}
}
Any Idea where im going wrong ? and how to tackle this problem ?