Forum Discussion
Sangeethkumar
2 years agoHonored Guest
Unity VR UI canvas popup
How can I open a UI canvas panel when an object is clicked by VR controller in Unity VR? I want to implement this functionality where clicking on an object in a Unity VR environment triggers the opening of a UI panel. How can I achieve this? If you have any insights or suggestions, please share them. Thank you!
3 Replies
Replies have been turned off for this discussion
- jtriveriStart Partner
This is more of a general Unity question than something Oculus-specific. I don’t know what interaction system you’re using, but you could look up how to detect interactions on an object with your system of choice. You could have an initially-deactivated canvas activate when the user interacts with the object.
- SangeethkumarHonored Guest
I want to use an XR device simulator to interact with objects via raycasting. When I point at an object and click the trigger button (mapped to the left mouse button), I want a canvas panel to pop up in 3D space. How can I achieve this?
As jtriveri mentions, this is just a Unity dev issue. Not really related to XR. Your UI canvas should be in World Space and scaled appropriately but beyond that you're just dealing with enabling a gameObject when the trigger button is pressed. There's a number of ways to do this depending on whether you use the new or old input system, as well as whether you're on OpenXR or OculusXR.
If you're using the new input system and OpenXR this video (and the one it links to) might help with getting inputs. https://www.youtube.com/watch?v=18_JMPKAlTE
If you're using the Meta XR Core SDK (i.e. have access to all Meta's helper scripts and prefabs) then this tutorial will walk through the process of getting button input:
https://developer.oculus.com/documentation/unity/unity-tutorial-basic-controller-input/
Note that the trigger isn't like one of the other buttons (A/B/X/Y) which have Down / Up states:
e.g.// If user has just released Button A of right controller in this frame if (OVRInput.GetUp(OVRInput.Button.One)) { // Do something }
Instead, the trigger gives you a float which you need to evaluate:
e.g.// While user holds the left hand trigger if (OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger) > 0.0f) { //Do something }
You'll probably not want to constantly evaluate that float, but that's something you can google and learn more about on your own 🙂
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 6 months ago
- 11 months ago
- 2 years ago
- 6 months ago