Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop UI Button OnClick() event when selecting a file/folder when using XR Interaction Toolkit #129

Open
yaelmartin opened this issue Mar 13, 2023 · 0 comments

Comments

@yaelmartin
Copy link

yaelmartin commented Mar 13, 2023

Unity version : 2021.3.17f1

When using the default "Complete XR Origin Setup" in the XR Interaction Toolkit (tested with 2.3.0 pre-1, and 2.3.0) package,
UI Buttons will trigger their OnClick() event twice/infinitely when calling a StandaloneFileBrowser.OpenFilePanel(); somewhere AND a file is selected.

-StandaloneFileBrowser.OpenFilePanel() isn't asynchronous. While using a synchronous function in VR isn't a great idea, maybe my fix could help someone in the future.

(Each time I wrote "Clicking a UI Button" means a button calling the function StandaloneFileBrowser.OpenFilePanel(); )

Clicking a UI Button located in canvas World Space with the VR controllers:
-If a file/folder is selected in the first pop up explorer using the desktop mouse without pausing VR (ex: opening SteamVR dashboard), high chance of the button and pop up explorer being called another time.
-If a file/folder is selected in the first pop up explorer while the SteamVR dashboard is opened, there is less chance of the button and pop up explorer being called another time.

Clicking a UI Button located in a canvas Screen Space Overlay from the desktop Unity window and a mouse:
-If a file/folder is selected in the first pop up explorer, the button WILL be called another time and a new pop up explorer will appear.

Fix I found that doesn't seem to break the XR experience:
-Disable the EventSystem component or entire gameobject inside the "Complete XR Origin Setup".
-Attach a new EventSystem component to an active gameobject in the scene (a new XRUIInputModule component will automatically attach)

Note: calling the same function wich calls the StandaloneFileBrowser.OpenFilePanel() in a XRGrabInteractible Activate() Event will work without opening a second pop up explorer window.
I have now found that by using the reproduce steps below, the window will continue to appear as long as you select a file!
The dekstop Canvas issue is always present. The bug seems to be more prone to happen on a VR WorldSpace canvas the more demanding the scene is. Action event on a XRGrabInteractable won't ever fire twice.

To reproduce :
Import and load the XR Interaction Toolkit DemoScene.unity in Assets\Samples\XR Interaction Toolkit\2.3.0-pre.1\Starter Assets
Import UnitySandaloneFileBrowser
Create a new cube and attach the provided DebugCube.cs script (DebugCube.cs)
Make a ScreenSpace UI canvas with a button (for the desktop view)
Make the button call the Click() function of the DebugCube
Enter play mode
Click on the Button. If you select an item in the window, another explorer window will appear, the int numberOfClicks in the DebugCube will increase. This is looping.
Now try my fix. The button OnClick() event should now be only called once.

@yaelmartin yaelmartin changed the title Double onclick button UI issue when working with XR Interaction Toolkit XR Interaction Toolkit, Infinite loop UI Button OnClick() event when selecting a file/folder Apr 1, 2023
@yaelmartin yaelmartin changed the title XR Interaction Toolkit, Infinite loop UI Button OnClick() event when selecting a file/folder Infinite loop UI Button OnClick() event when selecting a file/folder when using XR Interaction Toolkit Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant