I'm considering translating my game to other languages, and I wonder if there's a workaround to have different fonts for different languages?
I'm using standard AC menus and subtitles, and a custom-made pixel font for latin letters. If I would to be implementing chinese or arabic support I would need to use other fonts, and wonder if this is feasible to implement.
Comments
// Get all menus
List<AC.Menu> allMenus = AC.PlayerMenus.GetMenus ();
// Iterate through each menu
foreach (AC.Menu menu in allMenus)
{
// Iterate through each menu's elements
foreach (AC.MenuElement element in menu.elements)
{
element.font = myNewFont;
}
}
You can attach this to a custom event named OnChangeLanguage
Use an OnEnable function if you want this to work from any time - as it'll register when the scene begins. OnEnable/OnDisable is what you generally want unless you ever want to use an event selectively.
Note that this won't cause the code to run when the scene begins, just that it can do - the code will be called whenever the language option is changed.
To get around this, place the same code in a custom Action, and insert that into an ActionList asset that's set to run when the game begins (assigned via the Settings Manager). You could actually then remove the code from the custom event, and simply have the event run this ActionList (though be sure to set the ActionList's When running field to Run In Background):
myActionListAsset.Interact ();
Sorry for raising this thread I thought I had it in the bag. But having an issue.
I don't see any font change when I run this based on your script Chris. trying to change font to Chunkfive as a test. Tried to specifically load the font and tried to publicly declare it the inspector.
public class ChangeFont : MonoBehaviour
{
}
Console shows font set but no font change occurs.
All menus are Uinty UI in scene based. Calling this method with Object Send message.
Using Unity 2021.1.6f1 , AC 1.73.3
What am I missing?
The original issue in this thread was related to AC-menus, so the script works by updating an element's font variable - which is read only by such menus.
For Unity UI menus, it's necessary to update the Text component itself.
A script for this can be found on the AC wiki here:
https://adventure-creator.fandom.com/wiki/Per-language_Menus
Thank you Chris. I saw that script long ago and forgot about it