Forum rules - please read before posting.

Dynamic menu size based on words lenght

Hi,
I have a little issue with standard menus in AC (options, main menu, etc). When I use original language it's all ok (dimension of menu and inside elements), but for some translations (ex. russian or german where the words are longer than the original languages) the menus don't fit to words size. I tried to change the menus settings (manual, automatic, etc), but I can't see differences.
AC 1.69.0 + unity 2017.1.1

Thank you very much.

Comments

  • edited September 2019

    Changing the Menu's Size field is one thing, but what of the elements themselves?

    Is this occuring with the default AC interface? Do these other languages rely on different menus / fonts?

    How about if you ignore the game's original language, and start the game using a translation? This can be done by checking Don't use at runtime? beside the original language in the Speech Manager?

    I shall attempt a recreation, but a Unity UI-based interface wouldn't have such an issue.

  • Hi Chris, and thank you.
    Actually I'm using default AC interface with a single menu for all the languages. I tried also with "don't use at runtime?" applied but nothing changes.
    Here the correct version: https://drive.google.com/open?id=18LPUqWmEJfJKiIUZ2PB2qGimMsb6htOI
    and here when I change the language: https://drive.google.com/open?id=1hjxVMfOtWfl2ImgvGbbPDJNGubkwCPrh

    I know it's possible to have multiple menus, but I think it' easier to have a dynamic menu size.

    Is it possible with AC default interface?

    thank you very much

  • edited September 2019

    Menus should be the correct size when re-opened. For menus that are already open, they'll need to be recalculated to adapt to the new text.

    You can do this by checking Resize every frame? in the Menu's list of properties, or by hooking into the OnChangeLanguage custom event to force a recalculation when the language is changed.

    Something like this, placed in a script named LanguageMenuSizes.cs, and present in your scene, should do it:

    using System.Collections;
    using UnityEngine;
    using AC;
    
    public class LanguageMenuSizes : MonoBehaviour
    {
    
        private void OnEnable()
        {
            EventManager.OnChangeLanguage += OnChangeLanguage;
        }
    
        private void OnDisable()
        {
            EventManager.OnChangeLanguage -= OnChangeLanguage;
        }
    
        private void OnChangeLanguage(int languageIndex)
        {
            KickStarter.playerMenus.RecalculateAll ();
        }
    
    }
    
  • Hi Chris, and thank you.
    I tried with "Resize every frame?" too, but nothing change, the menu has always the same size. The size is set to Automatic and Position Centred for menu 0: 'Options'. For the elements position is "Aligned", while Size is on Manual: this is the result (as expected) https://drive.google.com/open?id=1MOiXLDLXm4JSzevxIaDINq6VRiJI8aDy.
    I tried Automatic Size also for elements but I have un unexpected result: https://drive.google.com/open?id=1aM8QVZhnH5oGpu84CoaJ33BskHYSKKet
    As you can see the fill bar goes above the words and I can't align correctly.

  • If the elements rely on Manual size, then no - there won't be any change.

    I see your point about the fill bar when set to Automatic - but this is more a side-effect of the setting rather than a bug. In this case, you would need to set it to Manual, and widen it so that it'll be naturally large enough to show the translation text.

    Again, Unity UI offers much more control when it comes to this kind of thing - since you can attach e.g. "Content Size Fitter" components, and separate labels from slider controls much more easily.

  • Ok, thank you very much Chris

  • Hi, I took your advice and solved almost all the issues. The last one is about the translations of some parts of the menu. I replaced the AC menus with the new ones created in unity. The traslations are all ok except for the tranlations of the sliders (Music, Sfx, Speech). I created a slider and a text (ex. text "Music Volume" and the the slider), then I linked the new slider to the the field in AC. When I export the text seems the new text is not exported (maybe because I linked only the slider to AC menus). Is there a way to export also this text? The issue is only about the text linked to the sliders, all the other menu sections has not problems. Thank you very much.

  • edited September 2019

    Slider elements are not given a label property / direct translation when used in Unity UI-based Menus - the "Music volume" text field, for example, shouldn't be visible in the Slider's properties.

    You'll need to link the Text compoents to separate AC Label elements.

  • Hi Chris, thank you very much, but I can't use this workaround:
    maybe I'm wrong some passage. My Unity menù has text fields for every phrases I need (in this case Speech Volume, Music Volume and SFX Volume) and are all visible. In the AC Options menu, under TitleLabel I created a new label (SpeechLabel) and, under Linked Text I linked he Speech Volume text of my Unity menu. But when I gather and export, AC seems to export the label text under the linked text (it exports the word Label) and when I translate it in other languages, it maintains the text of my unity menu, like if the new labels in AC menu weren't there. So I can't understand if the new label added (in AC menu) works or not. It seems that it shows always the text of my Unity menu that can't be translated. Thank you again.

  • The Slider element's "Label" property is only used (and displayed in the Menu Manager) if the Menu's Source is set to Adventure Creator.

    A bug exists, however, that causes this field to be gathered up by the Speech Manager and listed in "Gathered text" / CSV exports. It may be that the "Label" text you're getting is actually coming from the Slider element (which'll be ignored by your game).

    Let's see some screenshots - your new Label should get translated just as the "TitleLabel" is: there should be no difference between them.

  • Hi Chris,
    here some screenshots:

    When I gather text, I see AC finds 3 new lines, and I translate in the CSV file. Also import seems to works (AC imports new lines), but when I change the language in game the only texts with issue (so do not translate) are Music Volume, Speech Volume and SFX Volume. All the others are ok (also TitleLabel).

    I see now the version 1.69.1: are there some corrections for this issue?

    Thank you.

  • The Text components are not correctly updated because they have no associated Constant ID component - denoted by the "save" icon in the Hierarchy.

    The Label properties show it's linked to an ID with a value of "126198". I don't know if that's linking to something else in the Hierarchy, but it doesn't appear to be connected to the "Options_TextVolume" you've got selected in the second screenshot, as it has no ID.

    Try dropping the UI prefab back into the scene, re-link it to the Menu Manager, and apply changes made to the prefab before removing it from the scene. The Text component will need to have a Constant ID component whose value matches that listed in the Menu Manager - but the above steps should automate this.

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.