Forum rules - please read before posting.

Improved menu management

I know this is an issue even for people writing all their code in C# with Unity, but it would a great feature in AC to have the following menu improvements when you have multiple input boxes and use Unity UI elements:

- Be able to use the Tab key to move between input boxes
- Be able to automatically have the cursor placed within the first input box (If I recall, this is possible for pure AC menus, but not when you link an AC menu to Unity UI)

Comments

  • As this involves Unity UI and the Event System, such functionality should be done through custom scripts, e.g:

  • Thanks for the link, avoids me having to code it. Great support as usual Chris.
  • Hi Chris,

    Tried the code you had linked to above, but I have an issue.

    In the editor, I'm setting the values of the tabbableInputFields array to the different tabbed fields on my Unity UI canvas linked to an AC menu. When the code runs and tab is pressed, it does detect an object with the same name as my menu elements, but it doesn't appear to be the same object (has a different ID).

    I was supposing I just had to drag my menu elements from my canvas in my scene to the script edit boxes in the editor, but I'm apparently missing something. I would reference the AC menu elements if possible, but this doesn't seem to be possible within the editor (or I missed it).

    Any ideas?
  • Is this an in-scene UI canvas, or is it spawned by the Menu Manager at runtime?

    The script's supposed to be placed on the Canvas prefab, rather than on an object in your scene.

    If necessary, you could replace GameObject references with the AC menu element by name.  An element reference can be retrieved with:

    MenuInput myInput = PlayerMenus.GetElementWithName ("MyMenu", "MyInputElement") as MenuInput;
    GameObject linkedGameObject = myInput.uiInput.gameObject;

  • edited May 2018
    It makes sense, didn't think of that. Now that it's on my canvas and saved back to its prefab, it works fine.

    Just need to create a small pause, as the code is detecting the tab key many times and moving between the fields rapidly. I updated the Update() in the code for this, updated code: http://pasteall.org/978051/csharp

    Thanks Chris.
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.