PlayerInput.DeactivateInput() doesn't deactivate UI button

I have some UI-buttons which I want by a cutscene blocked from Input.

I use the code:

using UnityEngine.InputSystem;
private PlayerInput input = null;
private bool buttonsDone = false;

private void Awake()
{
input = gameObject.AddComponent<PlayerInput>();
buttonsDone = false;
}

void Update()
{

            if(!buttonsDone)
            {
                input.DeactivateInput();
                input.enabled = false;
                Debug.Log("DeactivateInput()");
                buttonsDone = true;
            }
}

But this doesn’t work. The arrow-keys on keyboard and gamepad are deactivated but if I press a joystick-button or “Enter” on the keyboard the input is still recognized and triggers the selected button. Same with the mouse, the clicking on the button triggers too and the button is highlighted if the mouse pointer is over the button.

UI Input is handled by the Input module that accompanies your Event System component. If that’s active, UI elements will still recieve input events.

You can either disable the input module, or disable the UI components.

1 Like

So I can disable the EventSystem?

What do the docs tell you?

https://docs.unity3d.com/Packages/com.unity.ugui@2.0/api/UnityEngine.EventSystems.StandaloneInputModule.html#UnityEngine_EventSystems_StandaloneInputModule_DeactivateModule

1 Like

Thanks. Sometimes I am overwhelmed with all the documents.