Forum rules - please read before posting.

Cycle menu option with Left/Right input

Hey hey again! I'm looking into setting up a menu where the menu item that is currently selected can be cycled through using left and right on either the keyboard or a controller. From what I've found I only have the option to cycle when using the cycle button. I've tried putting the horizontal axis as an alternative button but that will cycle even when the menu item is not currently selected AND also it only goes forwards, which means clicking left still cycles right.

Is there a way to get this setup and working just through AC? Anything I'm missing there?

Comments

  • I'm not sure what you mean by "cycle button". AC does have dedicated CycleInteractions / CycleCursors inputs, but these are special-case when dealing with Interactions. What kind of elements are you looking to cycle through?

    If your Menu is rendered with AC (i.e. not Unity UI), then navigating elements with the keyboard is done with the Horizontal input automatically - provided that the Menu is directly-navigable at the time.

    See the Manual's "Navigating menus directly" chapter for details on how this aspect works.

  • I am essentially making a password puzzle where the player is presented with a menu of 10 items. Each item is just a text field with a number. Moving up/down will simply navigate through the menu but pressing left/right should cycle the number on that selected item (so say it's set to 1, pressing right changes it to 2 and pressing left would cycle back to 1). The solution is to assign the correct number to the correct menu item.

    For style purposes I need to use Unity UI and not AC UI. I say cycle button because when I assign the menu items to cycle in the menu manager nothing will happen if I move left/right and it will only cycle to the next number if I press the confirm button (as if it's just a regular button). Is there any way the left/right functionality can be applied to Unity UI as well or that needs a custom script?

  • A Cycle element is intended to be a single-slot button that changes each time it's clicked. Typical usage is for e.g. a Language button that rotates between the game's languages each time it's clicked.

    If you want to have multiple "items" be arranged in a line, and be navigable, you'll need to make them UI Buttons and then map them either to individual Button elements.

    The connecting to AC's Menu Manager isn't a strictly necessary step, in so far as to get direct navigation working. Try building the UI in a separate scene, without use of AC, to get the behaviour you want first - and then only link it to AC once you want to add the click functionality.

  • Hmm perhaps I'm not explaining this well. I'm not asking about items arranged in a line.

    Let's take the example back to the languages. Say I have 20 languages and I'm clicking through and accidentally pass the language I want. It sounds like AC doesn't offer any ability to go back in a cycle? meaning I have to tap another 19 times just to get back to that language I want. Like, if we could just assign a forward button to cycle to the next language and a back button to go back to the previous language then we'd be golden!

  • edited February 2021

    Sorry. Yes, I follow you now.

    It's not currently possible, but you raise a good point. I'll look to see if this can be implemented as an option.

  • Ah alright. Either way I really appreciate the replies!

  • I can confirm this will be made optional in v1.73.1.

  • Heya @ChrisIceBox, just coming back to this after the update. My menu is using the arrow keys to navigate so I could easily set InteractionB to be left however InteractionA is used as the confirm button so I cannot change that to be right. In the menu manager there is the option to get in an alternative input button which is almost perfect except it triggers the cycle even when the button isn't highlighted. Here is a gif to easily see the issue: https://drive.google.com/file/d/1LY68TXJp8A3KVMpieqckj89EMkkimf0t/view?usp=sharing

    Is there a way I can disable that alternative input button when the cycle is not highlighted?

  • edited February 2021

    Yes - you can hook into the OnMouseOverMenu custom event to enable/disable it based on whether you've selected the element or not. Despite the name, this event works for direct-navigation of menus as well:

    using UnityEngine;
    using AC;
    
    public class ToggleAlternativeInput : MonoBehaviour
    {
    
        private string menuName = "MyMenu";
        private string cycleName = "MyCycle";
        public string alternativeInput = "RightArrow";
    
        private void OnEnable () { EventManager.OnMouseOverMenu += OnMouseOverMenu; }
        private void OnDisable () { EventManager.OnMouseOverMenu -= OnMouseOverMenu; }
    
        private void OnMouseOverMenu (AC.Menu _menu, MenuElement _element, int _slot)
        {
            if (_menu.title == menuName)
            {
                MenuCycle myCycle = _menu.GetElementWithName (cycleName) as MenuCycle;
    
                if (_element == myCycle)
                {
                    myCycle.alternativeInputButton = alternativeInput;
                }
                else
                {
                    myCycle.alternativeInputButton = string.Empty;
                }
            }
        }
    
    }
    
  • Oh wow, I definitely would have never thought to use the OnMouseOverMenu event here, thank you so much for the help and script base! Tried it out and it works perfectly :)

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.