Holding UI Toolkit Button During Screen Change Causes New Scene Buttons to Stop Receiving Inputs

Hello,

I am currently working on a Unity project that utilizes both UI Toolkit and some UGUI elements. The project is configured to use both the old and new input systems.

Due to the mixed UI elements across different scenes, we are adding an EventSystem with an Input System UI Input Module to each scene. However, we are experiencing an issue where UI Toolkit elements (such as buttons) in a freshly loaded scene stop receiving inputs under certain conditions.

Issue Description

  • When we are in a scene with UI Toolkit buttons and hold down a button while transitioning to another scene, the newly loaded scene’s UI Toolkit buttons do not respond to clicks or touch inputs.
  • Conversely, if we do not hold down any button while changing scenes, the elements in the new scene function as expected.

Questions

  • Is this behavior expected?
  • Are we possibly misconfiguring our setup?
  • Are there any known workarounds for this issue?

Reproduction Steps

I have attached a reproduction project that includes two scenes:
ReproProject.zip (1.7 MB)

  1. Scene1: Contains a script that loads Scene2 after a 2-second delay.
  2. Scene2: Contains the UI Toolkit buttons that exhibit the issue.

To reproduce the problem:

  1. In Scene1, click and hold any button.
  2. Wait for Scene2 to become active before releasing the button.
  3. Attempt to click the button in Scene2, which will not respond.

Thank you for your assistance!

1 Like

Hi,
Could you please file a bug report Unity QA: Building quality with passion

Are there any progress about this bug, @karl_jones (idk, if there’s a bug report about this)? I think the same bug was happening in Unity 21 LTS too, we’re on Unity 6 (and I just saw that, this bug reported for 21 LTS). We were kinda solve the problem by deactivating and reactivating the EventSystem gameobject after a frame. But this isn’t working anymore (or wasn’t solving the problem completely before). It’s too hard to find a solution.

Right now, we’re disabling event system gameobject on scene Awake, then on an Update method, we’re looking for a touch or mouse down, if there’s a touch began or mouse down we’re reactivating the event system gameobject 0.1 seconds later (enabling event system in the same frame doesn’t work either). But it’s not always working. In the editor disabling and then enabling event system gameobject works; but I can’t know when to do this on runtime, of course.

And, also, even if the event system gameobject is disabled, UI Toolkit can receive all touch/mouse events. I think this is also confusing.

This bug is a huuuge problem, because it is constant, it is happening everytime, and it is hard to “solve” it. If there’s no bug report, we’ll report it when we got time. There are many many bugs and it is very time consuming trying to replicate them in a new, empty project and report them =(

I’m not aware of any bugs for this. Could you please file a bug report? https://unity.com/releases/editor/qa#bug-reporting

We updated the original repo zip from @beesuit to Unity 6 LTS (6000.0.37f1) and created a bug report ( IN-95277 ). Hope you can solve this quickly; because this affects our users.

1 Like

Hi,
Im looking at the bug report now.
I have only just started looking however as a workaround, have you tried keeping the same EventSystem instead of a new one for each scene?

Try adding this script to the EventSystem GameObject.

using UnityEngine;

public class KeepAlive : MonoBehaviour
{
    void Start()
    {
        DontDestroyOnLoad(gameObject);
    }
}

It fixed the issues in the reproduction project for me.

1 Like

Actually, that might work for us too! I’ll try as soon as possible and give feedback. Might there be any catch to watch out for? We’ll test UI Toolkit, UGUI, Pointer events (raycasting ro a gameobject, etc) and of course, game controller.

1 Like

Looks like the workaround is working! But, I had to implement a little different singleton system, because we need EventSystem game object in every scene in the editor (and, leaving EventSystem enabled in other scenes doesn’t work).

I set all Event System game objects’ tags (except the scene at index 0) as EditorOnly and disabling InputSystemUIInputModule and EventSystem components. Then created a singleton that sets its static instance in Awake. And in Start method, I am checking whether its EventSystem and InputSystemUIInputModule components are disabled. Then, I am enabling them if they’re not. I think I explained it a bit complicated :sweat_smile:

I also have been notified that this bug has been resolved and pending for internal check and release. So it might take a while of course. Thank you for the fix :muscle:t2:

Here’s a little example script. Normally, I’d serialize the component references, but for this workaround I didn’t:

using UnityEngine;
using UnityEngine.InputSystem.UI;

public class EventSystemFixer : MonoBehaviour
{
	public static EventSystemFixer Instance;

	protected void Awake()
	{
		if(Instance == null)
		{
			if(transform.parent != null)
				transform.SetParent(null);

			DontDestroyOnLoad(gameObject);
		}
		else if(Instance)
		{
			Destroy(gameObject);
		}
	}

	private void Start()
	{
		var eventSystem = FindFirstObjectByType<UnityEngine.EventSystems.EventSystem>();
		var inputModule = FindFirstObjectByType<InputSystemUIInputModule>();

		if(!eventSystem.enabled)
			eventSystem.enabled = true;

		if(!inputModule.enabled)
			inputModule.enabled = true;
	}
}