VRTK icon indicating copy to clipboard operation
VRTK copied to clipboard

Mouse click on VRTK UI Canvas along with UIPointer possible?

Open pampas93 opened this issue 8 years ago • 13 comments

Using the vrtk UI canvas, is there a feature or property that could be used where, Both Oculus touch's pointer and the mouse interaction can be used?

For now, The canvas is made World space and interactable with Oculus UI pointer. How can make the UI elements be interactable with mouse as well?

pampas93 avatar Oct 10 '17 22:10 pampas93

Unity's UI system only allows using one input module and ours is just a VR input module. I think we only allow mouse stuff on non-VRTK_UICanvases, so if you want to use one with both you're out of luck.

Maybe there's an easy way to support mice by just emitting pointer events from the mouse to our UI stuff? I don't really know 😄

bddckr avatar Oct 11 '17 08:10 bddckr

A more important question is what the purpose of supporting both is. Is it because you want to click in the editor game window, click in the spectator view, or because you want to also support playing your game with a mouse and keyboard?

dantman avatar Oct 16 '17 12:10 dantman

Any of the screen space canvases should work for mouse interaction. The example scenes use the SDK Setup Switcher prefab that offers such a GUI which isn't visible in the HMD.

bddckr avatar Oct 17 '17 05:10 bddckr

@dantman I was going for an application in which the UI could be controlled by the user using the Oculus, and the user outside the oculus (in front of the system).

pampas93 avatar Oct 19 '17 16:10 pampas93

@bddckr Mouse interaction works fine when I make the canvas mode to Screen space. But this disrupts the control from the Oculus touch.

pampas93 avatar Oct 19 '17 16:10 pampas93

I have a similar situation where I have a non-VR camera (rendered on monitor) that needs the ability to click on VRTK_UICanvas items alongside someone using the Vive.

Minicholo avatar Nov 03 '17 09:11 Minicholo

As I said: Unity's event system only allows one active input module. If you find time to basically merge our VR one with theirs (which does mouse, keyboard and touch) go for it!

bddckr avatar Nov 03 '17 10:11 bddckr

Y'all play nice please, just make a live stream example for the peeps who don't know how to integrate the. Script. It'll take what 5-10minutes tops

On Nov 3, 2017 5:23 AM, "Christopher-Marcel Böddecker" < [email protected]> wrote:

As I said: Unity's event system only allows one active input module. If you find time to basically merge our VR one with theirs (which does mouse, keyboard and touch) go for it!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/thestonefox/VRTK/issues/1554#issuecomment-341666065, or mute the thread https://github.com/notifications/unsubscribe-auth/AfRctsBZWWHRq3eoAFjr6VhaC2iNRhhbks5syum5gaJpZM4P0rZR .

FreakinKat avatar Nov 03 '17 11:11 FreakinKat

@FreakinKat Not sure if bot, spam, sarcasm or dumb.

The technical issue was explained and hints have been given to add support for mouse interactions. The actual UI VR support is working just fine and is explained by an example scene and the documentation.

bddckr avatar Nov 03 '17 11:11 bddckr

Someone being a dick with my account plz ignore the comment. It's unauthorized use and not me.

On Nov 3, 2017 6:24 AM, "Christopher-Marcel Böddecker" < [email protected]> wrote:

@FreakinKat https://github.com/freakinkat Not sure if bot, spam, sarcasm or dumb.

The technical issue was explained and hints have been given to add support for mouse interactions. The actual UI VR support is working just fine and is explained by an example scene and the documentation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/thestonefox/VRTK/issues/1554#issuecomment-341678261, or mute the thread https://github.com/notifications/unsubscribe-auth/AfRctvPK5DoB8cTEv3xkdNjJlfpPoy0Vks5syvf8gaJpZM4P0rZR .

FreakinKat avatar Nov 05 '17 09:11 FreakinKat

Hello guys, I was confronted to that need. It's extremely simple to solve (i dont know which version of VRTK i have but one of the latest).

Just make VRTK_UICanvas inherit GraphicRaycaster (probably there is also an extra change to do). And override the necessary functions (OnEnable, OnDisable, OnDestroy) with base calls.

public class VRTK_UICanvas : GraphicRaycaster
{
[...]
        protected override void OnEnable()
        {
            base.OnEnable();
            SetupCanvas();
        }

        protected override void OnDisable()
        {
            base.OnDisable();
            RemoveCanvas();
        }

        protected override void OnDestroy()
        {
            base.OnDestroy();
            RemoveCanvas();
        }
[...]

Cheers!

Eraile avatar Jan 15 '18 18:01 Eraile

@Eraile I tried your solution, but my mouse clicks still have no response on the menu.

pampas93 avatar Feb 02 '18 19:02 pampas93

Hi there,

you can simply reactivate the GraphicsRayCasters via Script. Just add this script to the "VR Simulator" GameObject that is beneath "[VRTK_SDKSetups], and use the Simulator as main camera.

Works like a charm.

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

public class ReactivateRayCaster : MonoBehaviour { void Start() { StartCoroutine(EnableAllRaycasters()); }

public IEnumerator EnableAllRaycasters()
{
    yield return new WaitForEndOfFrame();
    yield return new WaitForSeconds(0.1f);
    // find all canvases in scene
    GraphicRaycaster[] Raycasters = FindObjectsOfType<GraphicRaycaster>();
    foreach (GraphicRaycaster g in Raycasters)
    {
        g.enabled = true;
    }
}

}

aignermax avatar Jan 17 '20 16:01 aignermax