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.
- The code didn’t work outside the sample. It always threw the following exception:
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:
- Leaving the
m_RebindOverlay
member unassigned causes the following error and the code doesn’t work:
UnassignedReferenceException: The variable m_RebindOverlay of UIRebindInput has not been assigned.
Don’t use the Elvis operator to check for null:
m_RebindOverlay?.SetActive(false);
Use != null instead:
if (m_RebindOverlay != null)
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.
8269290–1083300–RebindActionUI.cs (16.4 KB)