Forum rules - please read before posting.

Changing the text of a UI

Hello, I'm French and I use Google translation.
I would like to integrate a puzzle into a 1st person game, a bit like in the tutorial "Combination Lock".
For this, I created a canvas with 10 buttons from 0 to 9 with Box Collider et HotSpot.
Above I have the display with a panel and 4 UI Text objects (for the 4 digit combination to find).
Initial text is 0 (0 0 0 0), and I would like to change it when I press a button.
I created the Button:Use event, but I'm stuck on accessing the Component Text of the display.

Thank you.

Comments

  • Welcome to the community, @Kte.

    To manipulate UI components at runtime, it's best to connect it to AC's Menu Manager, as this makes it simple to display AC variable values in your UI.

    Working with Unity UI and AC's Menu Manager is a broad topic, but a tutorial can be found here (in text) and here (in video). The Manual's "Unity UI menus" chapter also details the process.

    To link your four UI Text objects, you'll want to create four Label elements in your new Menu, and map each Text component to its own Label element.

    Once linked, you can update their text values by linking each Label to a Global variables (in the Variables Manager). A tutorial on this process can be found here.

    This is all general advice, though - if you'd like detailed advice on any specific issue you encounter, share some screenshots so that we can see your exact setup.

  • Thank you very much for all these explanations, I will try.

  • Hello and thank you again,
    I made progress but... not all the way.
    I have my display which is bound to variables. When I manually change the value of these variables during the game, it works. But I can't manage to impact the variable by pressing a key:
    Capture-d-cran-217.png

    I created 2 menus:
    Emplacement and Clavier which has 12 buttons.
    Capture-d-cran-216.png

    The Emplacement menu seems correct, but I don't know if it's the assignment of the buttons of the Clavier menu, or if it's the action to change the global variable to the hotspot that is the problem.

    Capture-d-cran-218.png

    Sorry if I wasn't very clear, but I can explain again.

  • If both the buttons and the digit display are in Menus, there's no need for a Hotspot - other than to have it display in the first place.

    What are the contents of the Button ActionLists, e.g. Clavier_Button1_OnClick? It should be these ActionLists that update your variable values, rather than a scene-based Interaction.

  • I removed the Hotspots from the "Clavier" keys, and the collider boxes too, but that didn't change anything.
    I'm going step by step, so for now my Action List is minimal. I just want to change the var_slot1 variable since its value determines the display well.

    Here is Clavier_Button1_OnClick:
    Capture-d-cran-219.png

    I feel like my "Clavier" menu is not well connected.
    Capture-d-cran-220.png

    To be able to fill in the boxes, I had to create a "Clavier" Prefab.
    Capture-d-cran-221.png

    Is this the correct procedure?
    Thank you.

  • One more item:
    In the "Clavier" menu, if I drag "Touche1" from the "Clavier" Prefab into the Linked Button box of Button #1, it works.
    But when I stop and do it again, it doesn't work anymore.

  • If the "Emplacements" menu is before the "Clavier" menu, the Var_Slot1 variable is modified to 1 by clicking on the 1 key.
    If it is the opposite, the manual change of the variable Var_Slot1 modifies the display.

  • The procedure looks OK from the screenshots - you can check that the ActionList is working by clicking "Run now" in its Inspector to run it manually at runtime.

    AC will use Constant ID numbers to connect your Button elements in the Menu Manager to your Touche objects. Your third screenshot yesterday shows that the recorded ID value is 9156 - this should be added automatically by AC when assigning the Touch objects into the Menu Manager when viewing the Clavier prefab in Unity's Prefab Mode.

    Check that the Constant ID value on your Touche1 object matches that listed in the Button1 element's properties. If they don't, re-drag Touche1 into the "Linked Button" field and make sure the changes made to it are saved.

    You're welcome to PM me your "Escape" subfolder to examine directly.

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.