Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Disabling Navigation actions does not prevent navigation

Discussion in 'UI Toolkit' started by jnhackleman, Apr 13, 2021.

  1. jnhackleman

    jnhackleman

    Joined:
    Apr 24, 2017
    Posts:
    12
    I'm struggling to find out how to properly set up UI Toolkit events to work with the new input system...

    I am using 2021.1.2f1, UI Toolkit preview 14, and the player is set to use the New Input Package only.

    I have my game objects set up correctly, I think... (I'm also struggling to find up to date documentation on how to do some of these things)





    However when I call my Actions.UI.Navigate.Disable - the ui seems to still receive navigation events, and focus changes on the elements.

    Can anyone help me out? Thanks
     
  2. jnhackleman

    jnhackleman

    Joined:
    Apr 24, 2017
    Posts:
    12
    I've noticed that if I actually set my Navigate Action to None: then the navigation events are not fired as I would expect... But shouldn't disabling it during runtime do the same thing?
     
  3. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    198
    The reason is probably because you have two types of Event Systems that are competing for events right now: the InputSystemEventSystem (UI Toolkit only) and the EventSystem + InputSystemUIInputModule (UGUI).

    Unfortunately, the combination of [2021.2 + UGUI + UI Toolkit + new Input System package] doesn't fully work right now, pending an update of the Input System package to support that situation (shouldn't be too long, the fix is done already so it's just a matter of getter the next package update ready).

    If you want to work with UI Toolkit + new Input System package, for now you can the UGUI EventSystem from your scene, as well as the InputSystemUIInputModule that relates to it. When we get all of our things properly aligned as far as package interaction goes, you will be able to use UGUI's EventSystem to drive your UI Toolkit events, in which case you will be better off removing the InputSystemEventSystem component instead and keep the UGUI stuff only.

    If you really need to have UGUI at the same time, there's a workaround so that both UI systems ignore each other. You can call EventSystem.SetUITookitEventSystemOverride(null, false, false). Just make sure you call it before loading your scene or before all your event-related components are enabled (InputSystemEventSystem and EventSystem).
     
  4. jnhackleman

    jnhackleman

    Joined:
    Apr 24, 2017
    Posts:
    12
    Thanks for the reply - really the only reason I added the ugui one was because we couldn't figure out how to get pointer interactions with gameobjects in the scene without it. I'd love to drop the other one if the UITK one can handle out mouseover our game-boards or interaction at a gameobject-in-the-world level.

    Can this be done?
     
  5. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    198
    We're in a bit of a strange place right now because of the Input System package not being fully compatible with UITK when used along with UGUI. Unfortunately you can't use UITK's InputSystemEventSystem to get pointer interactions with GameObjects, that's really the UGUI EventSystem that does that.

    So basically you need to do one of the following:
    1. Don't use the new Input System for now. Rely on legacy input until the fix is out. Then remove InputSystemEventSystem since you don't need it anymore. If you have the UGUI EventSystem properly set up, UITK will see it and automatically hook into its events.
    2. Wait for next Input System package update: it will contain the fix that you're needing. Then remove InputSystemEventSystem and rely on UGUI's EventSystem.
    3. Keep all like it is, but call EventSystem.SetUITookitEventSystemOverride(null, false, false) at some point before loading your scene, like I was saying in my previous answer. This will make both event systems ignore each other, until you have the fix that you need from the Input System update. When that fix is out, then revert back to what you had and go to point 2.