Forum rules - please read before posting.

Fonts and languajes

Hi, I´m trying to manage different fonts for different alphabets. I look there is a tread with something like that but I had some stuff because I have different UI system. I have some UI with the UI for unity and other using ac.
I don´t know if the best its to make in all the scenes a check for language and in the different UI change or if there is a simple and more effective way to change the font.


  • edited June 2018
    It'll be a lot easier to rely on Unity UI for all of your Menus, because then all style options are controlled via components and not by the Menu Manager.

    You can detect a change in the language via the OnChangeLanguage custom event - see the Manual's "Save scripting" chapter.

    Then you can run something like:

    Menu[] allMenus = PlayerMenus.GetMenus ().ToArray ();
    foreach (Menu menu in allMenus)
      Text[] texts = menu.canvas.GetComponentInChildren <Text>();
      foreach (Text text in texts)
        text.font = myNewFont;

  • Ok well, the OnchangeLanguage event i got it. 
    Now i have the simple if language number is x then the code you posted. But i had a few problems like this line Menu[] allMenus = PlayerMenus.GetMenus ().ToArray (); and in the Text[] texts = menu.canvas.GetComponentInChildren <Text>(); line.

  • What problems, exactly?
  • error CS0029: Cannot implicitly convert type `AC.Menu[]' to `Menu[]'
     error CS1061: Type `Menu' does not contain a definition for `canvas' and no extension method `canvas' of type `Menu' could be found. Are you missing an assembly reference?

    That 2 errors. 
  • You likely have a conflict with another script named "Menu" in your game.

  • Nice, i think it´s working but the problem is that didn´t found the text in the child. So i think that the problem now. 
  • OK, I'll look into it.  It might be that a dedicated "FindAllTextComponents" function (or similar) would be beneficial here.
  • Thanks Chris!
  • Well, the script actually works for me just fine.  What are your AC and Unity version numbers, and are these in-scene or prefab-based UI Menus?

    You say it "didn't find the Text", but do you mean all - or just some?  Is there a pattern between those it's finding, vs those it's not?
  • Unity 2018.1.0f2 (64-bit)
    AC 1.62.5
    Are prefab-based UI Menus, I think all the text didn´t find because nothing change the font.

    And the complete error:
    NullReferenceException: Object reference not set to an instance of an object
    LanguajeSelection.OnChangeLanguage (Int32 languageIndex) (at Assets/TANGO-UNITY/LanguajeSelection.cs:47)
    AC.EventManager.Call_OnChangeLanguage (Int32 language) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:763)
    AC.Options.SetLanguage (Int32 i) (at Assets/AdventureCreator/Scripts/Options/Options.cs:697)
    AC.MenuCycle.ProcessClick (AC.Menu _menu, Int32 _slot, MouseState _mouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuCycle.cs:490)
    AC.PlayerMenus.CheckClick (AC.Menu _menu, AC.MenuElement _element, Int32 _slot, MouseState _mouseState) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:2190)
    AC.PlayerMenus.CheckClicks (AC.Menu menu) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1868)
    AC.PlayerMenus.CheckForInput () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1962)
    AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:299)
  • The script assumes that all Menus have a Canvas attached.  Try this, it'll do a null-check and spit out some Console logs as well:

  • That suggests that Options, OptionsPausa, Subtitles, narrador, Conversation were updated successfully.  Was that the case, and what is the difference between those Menus and the others?

    I apologise, but the updated script only made adjustments to the font-change when re-assigning the old font, not the new.  Try this:

    Is it also the case that the font with the new language is #2, as listed in the Speech Manager?
  • Thanks!! now it´s working 
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.