Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question UI submit and the cancel actions on press

Discussion in 'Input System' started by Four-Lights, May 7, 2021.

  1. Four-Lights


    Jul 14, 2018
    I am using Input System 1.1.0-preview.3.
    In Input System 1.1.0-preview.2 one of the changes was:
    • The submit and the cancel actions of the UI input module now trigger on release instead of press. This makes the behavior consistent with clicks triggering UI response on release rather than press.
    This new behavior breaks parts of our dialogue system and isn't what we want on other buttons either. What works is editing InputSystemUIInputModule.cs and change it there.

    Code (CSharp):
    1. if (cancelAction != null && cancelAction.WasPressedThisFrame()) // changed from WasReleasedThisFrame()
    2.                     ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
    3. if (!data.used && submitAction != null && submitAction.WasPressedThisFrame()) // changed from WasReleasedThisFrame()
    4.                     ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
    However, instead of messing around with he plugin itself (and probably having to do so after every update), what is the proper/clean way to change it back from on release to on press?