TomorrowTodayLabs / NewtonVR

A virtual reality interaction system for unity based on physics.
MIT License
788 stars 196 forks source link

UI laser pointer broken (sometimes) #120

Open ShacharWeis opened 7 years ago

ShacharWeis commented 7 years ago

I'm having a lot of problems with the laser pointer for the UI elements.

Sometimes it works perfectly, sometimes it locks to a fixed point that is at the corner of the display (moves with your head). The weird part, is that sometimes it works well, but after reloading the scene in Unity it stops working, and other times it doesn't work but starts working again after a scene reload.

It seems random and I can't figure out what changes in scene cause it to switch from a working mode to a broken one. All in all this is very frustrating. Any ideas?

zite commented 7 years ago

Are other people seeing this issue? I'm not able to reproduce it.

ShacharWeis commented 7 years ago

I have more information. I seems this happens only when the menu in question is moving, in my case, it's attached to one of the controllers.

JashanChittesh commented 7 years ago

I'm not sure if this is related but I found this doing research on a super-annoying Unity 5.5 "bug" that causes many in-VR laser-pointer based UIs to break when Unity loses focus. The symptom in that case is that you simply cannot click anything anymore, and also hover does not work anymore (in VR).

Turns out this is a change in Unity UI / EventSystem: They have added OnApplicationFocus and make the EventSystem pause on desktop systems, which causes Process to no longer be called in VR event systems.

munkeyxis commented 7 years ago

I've noticed that the laser pointer moves with the VR camera when using a Canvas set to World Space but no Event Camera is set. NVRCanvasInput is supposed to find all Canvas components in the scene and set their Event Camera to the "Controller UI Camera" which is instantiated after startup. But the coroutine that is supposed to do this doesn't seem to be working anymore and it never seemed to apply to canvases that were disabled during startup.

victorazzo commented 7 years ago

@munkeyxis nailed it. If you have a disabled canvas before startup, "Controller UI Camera" will never be assigned to this canvas. A workaround is to get the "Controller UI Camera" object by script from a canvas you know is enabled from the start and assign it to all other canvases. I ended up using another workaround, which was to have all my canvases enabled during startup and controlling which one is visible and interactable using a " Canvas Group" component.