Forum rules - please read before posting.

Gamepad Cursor Not Working With Unity UI Elements

Moving this from Cursor doesn't interact with Unity UI using input system and controller

When the cursor is being controlled by the gamepad, it doesn't react to UI elements (strangely the hover audio works, but everything else doesn't).
We're using the new Unity InputSystem, and I have tried the AC Cursor Position Preprocessor but that also didn't work.

The MouseTest.cs script from the thread above did make a change, but has some weird quirks (even with the last suggested edits).

Below is how the Cursor Preprocessor and evensystem is set up:

Comments

  • UPDATE!

    I just noticed that the Point action doesn't have the required stick input, I had just assumed that wasn't needed because of CursorHorizontal/CursorVertical.

    If anyone encounters the same issue, this is what our layout for the Point Action looks like now that it's working:

    In my previous screenshot I assigned InteractionA to Submit, inside the EventSystem, but that's not needed and might cause issues.

  • Try this script instead:

    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.InputSystem;
    using UnityEngine.InputSystem.LowLevel;
    using UnityEngine.EventSystems;
    using AC;
    
    public class MouseTest2 : MonoBehaviour
    {
    
        private Vector2 lastPosition;
        private List<RaycastResult> results = new List<RaycastResult>();
    
        void Update()
        {
            if (KickStarter.settingsManager.inputMethod != InputMethod.KeyboardOrController) return;
    
            Vector2 simulatedCursorPosition = KickStarter.playerInput.GetMousePosition ();
    
            var pointerEvent = new PointerEventData(EventSystem.current)
            {
                position = simulatedCursorPosition,
                delta = simulatedCursorPosition - lastPosition,
                pointerId = -1,
                pointerCurrentRaycast = new RaycastResult()
            };
    
            EventSystem.current.RaycastAll(pointerEvent, results);
    
            GameObject obToSelect = results.Count > 0 ? results[0].gameObject : null;
            EventSystem.current.SetSelectedGameObject(obToSelect);
    
            lastPosition = simulatedCursorPosition;
        }
    }
    
  • Thanks Chris,
    I made a small mistake on my end, check my last comment. The AC Cursor Position processor already works lovely! (even without using a MouseTest script)

  • Do you have a Controls asset set up for all three control schemes? I wouldn't mind taking a look at it, if you don't mind PMing me.

  • Hello. Neither Gamepad or Mouse Cursor is detected by (Unity UI) menus for me.

    I installed the input system, download and import the asset package. Then I added the integration through the new game wizard.

    The Event System prefab was assign to the menu manager as expected with its UIInputModule, Controls Reader and Player Input components.
    Did I miss any fundamental step? I've read multiple discussion and everybody seems to have the cursor working with menus out of the box.
    The gameplay works OK. Only having problems with menus.

    Can someone please advise what should I look into? 🙏

    Movement Method: Point and Click
    Input Method: Mouse and Keyboard (tried keyboard and controller, same problem)

    Unity 6000.0.26f1
    AC 1.82.0

  • Are you using the system cursor, or a simulated one (controlled via gamepad or keypad), or are you navigating menus directly?

    Is there an EventSystem already in the scene that would override the one assigned in the Menu Manager.

    Try a new project and importing the Input System template into the 3D Demo - does it work there?

  • I use both, System cursor when Input Method is Mouse and Keyboard and simulated cursor when using keyboard and controller input method.

    No, there is not event system in the scene. Only the assigned prefab in the Menu Manager.

    Yes, the Input System works perfectly in the 3D demo.

    Thanks.

  • Chris, the problem was because I was using the action Egine:ManageSystem OnStart to enable direct-nav in-game menus. Yesterday i was testing menus with direct nav and didn't delete this action afterwards. Sorry.

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.