Forum rules - please read before posting.

Cursor still active when hidden and highlighting UI button

edited October 2019 in Technical Q&A

I have an AC menu with some Unity buttons. One of the buttons is in the middle of the screen. I am not using the cursor on this menu, so it is locked using the action list player constrain -> cursor lock -> enabled (I am using a controller to navigate between the buttons).

My issue is that the button in the middle of the screen is permanently highlighted, along with whatever button has been navigated to by the controller. We believe that what is happening is that the action of enabling cursor lock (on player constrain) is putting it in the middle of the screen and hiding it, but not deactivating it, which is causing whatever button is in the middle of the screen to be highlighted. When I disable the cursor lock (or I don't put a button in the middle of the screen), the problem goes away.

If we are right, what do I need to do to have the cursor deactivate when hidden? If we are wrong, does anyone have any other ideas?

Cheers,
Jen

Comments

  • Welcome to the community, @Jen42.

    I'd say your hunch is correct - locking the cursor involves locking it's position, not it's behaviour.

    The mouse's control over a UI-based Menu should automatically be disabled, however, if the Menu is known by AC to be directly-navigated.

    Does the Menu pause the game, or is it open during gameplay? If during gameplay, be sure to use the Engine: Manage systems Action to set the Control in-game Menus property to True when the Menu is turned on.

    When this is the case, and your game uses AC's own EventSystem (spawned at runtime, and includes the Optional Mouse Input Module component), then that should prevent UI interactions with the mouse.

    Otherwise, post some more details in the form of screenshots and AC/Unity version numbers and we'll try to see what the issue is.

  • edited October 2019

    Hi Chris,

    Thanks for the fast reply. The menu does not pause the game and we are using AC's own Event system. I have tried setting Engine: Manage Systems: Menus to enabled and disabled and nothing is affected (hidden cursor still highlighting middle button).

    I have verified that the cursor is the culprit by tweaking your code to put the cursor in the bottom left corner when it is locked which fixes the problem (and then to double check, I put a button overlapping the corner and it highlights it).
    PlayerInput.cs line 391 and 595
    // Cursor position
    if (cursorIsLocked)
    {
    //mousePosition = new Vector2 (Screen.width / 2f, Screen.height / 2f);
    mousePosition = new Vector2(0, 0);
    }

    But obviously changing your code is not a maintainable way of working, especially as we update AC at every update and mousePosition is protected, so I can't override it.

    We are using the latest version of AC and Unity 2018.4.9f1 Switch version.

    What screenshots would be helpful to help you help me? It is a standard AC menu with standard Unity buttons and it is being called from an action list Menu -> Change state -> Turn on menu and then Menu -> select element.

  • I have tried setting Engine: Manage Systems: Menus to enabled and disabled and nothing is affected (hidden cursor still highlighting middle button).

    Don't disable the Menus system. My suggestion was to enable direct-control over in-game menus. Is this option not appearing in this Action? This should be visible so long as your Settings Manager's Input method is set to Keyboard Or Controller.

  • Ah I didn't see that. I have now tried enabled and disabled on 'Control in-game Menus' and neither worked. I still have a highlighted button.

  • I will attempt a recreation - can you share a screenshot of your Settings Manager?

    In the interest of extensibility, I shall also provide a way to override the default locked cursor position through subclassing.

  • Thanks, that would be very helpful.

    Here are my settings:

    https://drive.google.com/open?id=1fRmZy0HMaDwMfu8Q1oF4F0S1LNIHirPT

  • Seems to be somewhat erratic, and I'm not sure if this is a quirk of the Event System or not.

    What does help (though this won't be desired for all game types) is to prevent cursor interactivity completetly. This can be done by duplicating OptionalMouseInputModule.cs, modifying it so that allowMouseInput is always false.

    Attach this component to a new Unity EventSystem, remove the Standalone Input Module, and assign this as a prefab to the top of the Menu Manager. In the v1.70 update, I'll be virtualising a lot of functions so that it'll be easier to override such scripts through subclassing.

  • edited October 2019

    We use the cursor in the game occasionally, so we don't want to permanently disable it. We just want to disable it when we aren't using it. I think the cleanest solution is to just change your code as I have done until the update and then use the subclass to override the cursor position as you have suggested.

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!