Forum rules - please read before posting.

Trying to get the cursor working while menu is open with a controller

I've been porting a project that was originally on touchscreen over to a controller setup and there is the odd thing where i need cursor control on the right stick. Currently if there's a conversation playing the cursor works find but as soon as i open a menu it disappears. I can navigate menu's with the left stick but there's a couple of screens where i need the cursor active too. I've tried enabling it using the manage systems and various other combinations but they don't seem to work.

Any ideas?

Comments

  • What's your AC version number?

    By default, if your Input method is set to Keyboard Or Controller, then Menus that pause the game are directly-navigated (i.e. no cursor).

    This behaviour can be disabled, however, by unchecking Directly-navigating Menus when paused? at the top of the Menu Manager. If you right-click the label, you'll also get an API reference so that you can dynamically change this setting through script at runtime.

  • 1.66.2

    So if i check 'Pause game when enabled' on the menu setting and uncheck 'Directly-navigating Menus when paused?' it should give me the cursor?

    It's basically a little drawing mini-game and i want to try and keep the button/gui navigation on the left stick but use the right stick as a cursor for the actual drawing part.

    Thanks for your help!

  • It should, yes.

  • Sorry for the late reply i've only recently had a look at this again.

    Despite setting this i still can't see the cursor, is there any other setting that may be clashing or turning it off?

  • I'll need to attempt a recreation of the problem. Can you provide screenshots of your full Settings and Menu Managers (including the properties of the Menu in question)?

  • Sure can, i've also captured a bit of video of the menu if that is any help. I dropped a Debug.Log on line 612 of PlayerInput.cs in UpdateInput() and i'm moving the right stick while the menu is up, you can see the cursor position is updating but doesn't display, then towards the end of the vid when i show some conversation you can see the cursor position updating and drawing.

    https://youtube.com/watch?v=DCVvKTUKdko&feature=youtu.be


  • Thank you, I'll attempt a recreation.

  • While the simulated cursor appears for me, the wider issue is that Unity UI does not currently respond to it - because it's designed to only react to the mouse cursor, which is not the same thing.

    While switching your Menu's Source to Adventure Creator should allow it to react properly, please test this replacement to AC's OptionalMouseInputModule script, which should resolve it for Unity UI:

    https://paste.ofcode.org/xEHVyXRWrGSMSeSwUBH7jt

    Be sure to backup your project first, and please let me know the results.

  • Thanks for getting back! I've tried this but it doesn't seem to have made a difference, unless i'm missing something in the setup. I also tried it on the Switch.
    Also i'm not seeing the cursor anyway so it could be working fine and i just don't know...

    As a test i can kind of get this working if i trigger a conversation at the same time as showing the menu, i can rollover the button at least.. see this vid https://youtube.com/watch?v=A1GHztuGLHI

  • Yes, it's that rollover/interactivity that the script addresses. In order to "click" on an element, you need to invoke the InteractionA input - just as you would with an AC menu.

    As AC does not officially support Switch, let's keep to desktop platforms for the moment while we address the issue. Like I said, the cursor shows for me. Try using the New Game Wizard to create a new game with "Keyboard Or Controller" input, "Direct" movement, and the default AC interface. Uncheck "Directly navigate when paused?", and see if the cursor shows up then.

  • That works the cursor appears with the new default game settings!

    As such i tried my game again but swapped in the cursor settings for this new default one and that has also worked!

    I can't see any difference between the 2 though so not sure why this is... Maybe the object has been corrupted in some way, it has been past around a fair bit between unity versions and projects.

    Seem to be working though now, thanks for your help!

  • Chris, I'm having the same issue. Can you repost that script or let me know where it is? The one you used at https://paste.ofcode.org/xEHVyXRWrGSMSeSwUBH7jt
    I'm having to use AC 1.54c at the moment.

  • I don't have the above script, but the changes were implemented officially into AC. Try importing just the following script file from the latest release:

    /AdventureCreator/Scripts/Menu/OptionalMouseInputModule.cs

  • edited February 7

    Thanks Chris.

    I have upgraded to the latest version of AC 1.70.2 and I still have the issue where for all my Menu / Conversations items are "Unity UI Prefabs" and I cannot click on any of them. If I set them to Adventure Creator they work.

    The cursor shows up and I can move it. I can click to move around with the joystick ( which is set up correctly ) and the InteractionA button works. It lets me highlight items from Hotspots. I'm am running this on a PS4 / XBox in which it doesn't work. It seems to work on PC Standalone.

    Movement Method: Point and Click
    Input Method: Keyboard or Controller
    Directly-navigate Menus when Paused?: Unchecked
    Directly-navigate Menus during Conversations?: Unchecked

    Is there a part of the OptionalMouseInputModule I should focus on for more testing? I "feel" like there is a layer issue when going to console.

    Thanks.

  • Do any other Menus not work, e.g. Pause menus, or is it just the Conversation menu?

    AC does not officially support consoles, but you can try commenting out line 96 to force cursor raycasting at all times.

  • edited February 7

    No, no menus work, nor do the conversations. When I hit the InteractionB it pops up, but cannot select anything.

    [EDIT]
    No, it did not make any difference when I commented out line 96.

  • edited February 7

    Just a FYI to everyone, XBox ( and my guess PS4 and Switch ) doesn't support the GetMousePointerEventData. I'm trying to see about calling it from the Update method and see what I can get from that.

    I'm also going to assume it doens't like PointerEventData either.

  • Ok, I got it to work where it highlights. If you are using Unity UI Prefabs, make sure that you only have selection of "Raycast Target" on for the Button component and not on anything else.

    The leftClickState and the rightClickState are registering that the InteractionA and InteractionB buttons are working.

    To recap, in your Update function, call the "GetMousePointerEventData". Comment out lines to have the SetSelectedGameObject called all the time ( at the time of this writing, it's line 96.

    Verify your Raycast Target on your Unity UI Prefabs. Follow everything else in this thread above for the Menu toggle to get the cursor.

    Now to figure out the actual select method so activate whatever you clicked.

  • edited February 8

    I'm not really in a position to test this out, but if this way of working still triggers the OnMouseOverMenu custom event, you could feasibly trigger the element via AC, without having to manipulate any component.

    Something like:

    Menu overMenu;
    MenuElement overElement;
    int overSlot;
    
    private void OnEnable () { EventManager.OnMouseOverMenu += OnMouseOverMenu; }
    private void OnDisable () { EventManager.OnMouseOverMenu -= OnMouseOverMenu; }
    
    private void OnMouseOverMenu (Menu menu, MenuElement element, int slot)
    {
        overMenu = menu;
        overElement = element;
        overSlot = slot;
    }
    
    private void Update ()
    {
        if (Input.GetButtonDown ("InteractionA") && overElement != null && overMenu != null)
        {
            overElement.ProcessClick (overMenu, overSlot, MouseState.SingleClick);
        }
    }
    
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.
Do NOT follow this link or you will be banned from the site!