Search Unity

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,620
    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,620
    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.
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    Did my feedback make its way to someone on the input system team? o_O
     
  4. ZanthousDevelopment

    ZanthousDevelopment

    Joined:
    Jul 12, 2023
    Posts:
    12
    It made it to me at least. Thanks for the thread, this is still an issue in the version I tried 1.7.0 sample
     
    Peter77 likes this.
  5. Pauliusd

    Pauliusd

    Unity Technologies

    Joined:
    Nov 29, 2018
    Posts:
    4
    Thank you Peter, I've added your suggested code and it should be available once 1.8.0 fully releases out of pre-release.
     
    doompr and Peter77 like this.