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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Feedback "Rebinding UI" sample bugs & fixes

Discussion in 'Input System' started by Peter77, Jul 11, 2022.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,394
    I integrated the
    RebindActionUI
    code in my project and found the following issues. I attached the .cs file with the fixes, so you can diff it against what you have in your repo.

    1. The code didn't work outside the sample. It always threw the following exception:
    Code (CSharp):
    1. InvalidOperationException: Cannot rebind action 'Player/Fire[/XInputControllerWindows/buttonSouth]' while it is enabled
    Disabling the action before the rebind and enabling it afterwards seems to workaround the problem:
    upload_2022-7-11_19-52-16.png

    2. Leaving the
    m_RebindOverlay
    member unassigned causes the following error and the code doesn't work:
    Code (CSharp):
    1. UnassignedReferenceException: The variable m_RebindOverlay of UIRebindInput has not been assigned.
    Don't use the Elvis operator to check for null:
    Code (CSharp):
    1. m_RebindOverlay?.SetActive(false);
    Use != null instead:
    Code (CSharp):
    1. if (m_RebindOverlay != null)
    2.     m_RebindOverlay.SetActive(false);
    The Elvis operator doesn't work with UnityEngine.Object types in some circumstances. It seems to be a long standing issue, see this thread for details.

    There are also several ?? operators used on UnityEngine.Object types as well. I can't tell whether these actually work.
     

    Attached Files:

  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,394
    It would be beneficial when you move the "BindingId" code from
    RebindActionUIEditor.cs
    to a PropertyDrawer/Attribute and preferably have the classes in InputSystem and not in the sample project.

    This would allow to reuse rebind functionality more easily and you can already see from the sample project that such functionality is needed in a project anyway.