Enable/disable EventSystem?

I’m adding gamepad support to my game, and for the UI I decided to control the “cursor” with the gamepad, instead of using the EventSystem’s default navigation method. I have an alternate Input Module working.

At least it works if I launch the scene with the EventSystem activated. Deactivating the EventSystem will make it so the UI system reverts back to using the system’s cursor, which is fine, but it will not go back to the custom system if activated again.

How do I go about properly enabling/disabling the EventSystem and/or my custom Input Module?

I want both KBM and gamepad to be two different options the user can switch between at runtime.


In the top include the directory:

using UnityEngine.EventSystems;

Then in your code:

EventSystem eventSystem = GameObject.Find("EventSystem").GetComponent<EventSystem>();
eventSystem.enabled = false;

Then to enable again:

eventSystem.enabled = true;

I know this is late, but I could not find a good answer anywhere. So maybe this will help people in the future.

I guess what I really need is to be able to set the current Input Module.
currentInputModule is read only, and when you disable the EventSytem that becomes null and there doesn’t seem to be a way to set that again?