wacki / Unity-VRInputModule

MIT License
89 stars 33 forks source link

Intermittent raycast bug in Unity 5.5 #5

Open paulhayes opened 7 years ago

paulhayes commented 7 years ago

I'm getting an odd issue in Unity 5.5 ( in f3 and latest p4 ). Often the Canvas is not picked and the indicator graphical ray just shoots right though it. Stopping and Starting playback in the editor can fix/break it.

paulhayes commented 7 years ago

Think I've found the issue. Seems to be Editor related.

https://forum.unity3d.com/threads/baseinputmodule-broken-in-5-5.449206/

JashanChittesh commented 7 years ago

It took me a while to figure this one out but I finally found the issue: Some very smart person added OnApplicationFocus to the Unity UI EventSystem in 5.5, and this will pause the EventSystem when the application loses focus. That will result in Process no longer be called on our custom in-VR input modules.

I believe the only solution is to write our own implementations of EventSystem that don't to stupid things like that ;-)

paulhayes commented 7 years ago

Yeah that's a stinker. On one level it makes sense that they put that in their input code, but obviously it makes no sense for VR.

Another solution is we could listen for when a headset it donned ( At lease for the Oculus ), and use that to get application focus.

tkeene commented 7 years ago

Thanks everybody, this thread was very helpful in solving this issue.

https://www.reddit.com/r/Unity3D/comments/699rej/custom_pointerinputmodule_issues_when_window/

using UnityEngine.EventSystems;

public class CustomCanvasEventSystem : EventSystem
{
    protected override void OnApplicationFocus(bool hasFocus)
    {
        // Workaround because the default EventSystem implementation stops polling pointer input in our PointerInputModule if the application loses focus (such as when I use the desktop viewer to click on another application's window).
        base.OnApplicationFocus(true);
    }
}

This is a slightly annoying workaround. It would be nice if EventSystem had a checkbox or enum field for changing this behavior.