cancel
Showing results for 
Search instead for 
Did you mean: 

Use GearVrController with Selection Ray - Unity

davidbeloosesky
Explorer
Hi, I figure out how to add a GearVrController to a scene.
(Adding a OVRCameraRig, and Add GearVRController under the RightHandAnchor)
The controller follows the hand movements. 

But how can I add a selection options + a ray from the device to the scene?
I mean a ray that can select item, like in the Oculus store below:

z55w50ytmdyp.png




43 REPLIES 43

vivalavida
Honored Guest


I see, that code is for using the Gear VR touchpad, or Gear VR Controller touchpad to scroll a scrollable area, like a text field with long text. It's not something you can hook into.


hey sorry for shifting focus to this, but does the scrolling code work?
could you please maybe show which script handles this?
I was unable to find any references to scroll related variables.

JBivBeats
Protege
@oculus_gabor this works perfectly for me in the demo, but when I add the scripts needed I get the following errors in the raypointer script:

assets/drive in assets/RayPointer.cs(36,25): error CS1061: Type `UnityEngine.EventSystems.OVRInputModule' does not contain a definition for `OnSelectionRayHit' and no extension method `OnSelectionRayHit' of type `UnityEngine.EventSystems.OVRInputModule' could be found. Are you missing an assembly reference?


Assets/drive in assets/RayPointer.cs(61,25): error CS1061: Type `UnityEngine.EventSystems.OVRInputModule' does not contain a definition for `OnSelectionRayHit' and no extension method `OnSelectionRayHit' of type `UnityEngine.EventSystems.OVRInputModule' could be found. Are you missing an assembly reference?

Assets/drive in assets/RayPointer.cs(107,25): error CS1061: Type `UnityEngine.EventSystems.OVRInputModule' does not contain a definition for `activeController' and no extension method `activeController' of type `UnityEngine.EventSystems.OVRInputModule' could be found. Are you missing an assembly reference?


Assets/drive in assets/RayPointer.cs(132,29): error CS1061: Type `UnityEngine.EventSystems.OVRInputModule' does not contain a definition for `SelectionRay' and no extension method `SelectionRay' of type `UnityEngine.EventSystems.OVRInputModule' could be found. Are you missing an assembly reference?

Assets/drive in assets/RayPointer.cs(133,36): error CS1061: Type `UnityEngine.EventSystems.OVRInputModule' does not contain a definition for `SelectionRay' and no extension method `SelectionRay' of type `UnityEngine.EventSystems.OVRInputModule' could be found. Are you missing an assembly reference?


am I missing something?  I'm sure it's something simple that I may have missed, could you please take a look?

oculus_gabor
Protege
Hi @JBivBeats

You are not missing something, you have multiples of something 😛

When i originally wrote that blog, UI interaction scripts were not being shipped with Oculus Utilities for Unit. I think right around the 1.20 or 1.21 release, those scripts started getting included with the utils. The blog post uses a custom version of these scripts. I have the custom versions namespaced in a way that they can co-exist with the version in utils.

For example, searching for OVRRaycaster will result in 2 files

ybc9cf7bhf2o.png

Make sure to use the version if these scripts you are using is from the OVRInputSystem

jbnoss3nt14k.png

I'm going to be working on rolling my version of these scripts into the utilities, to avoid this issue; but i'm not sure how long that's going to take or what the ETA is.

~Gabor

mallmagician
Expert Protege
Thanks very much everyone for the perseverance with this. This will be very useful to me as I make the switch from game pad to oculus controller in my current project. 

alexvilch
Protege
Could you point out how to attach the ray to Oculus Rift touch controller ? Right or left hand for example from Avatar SDK example ? I've tried to add VRRaycaster to right hand but just see only some blinking.

Thank you,

Alex

mbrkl
Honored Guest
I would also appreciate to have an equivalent sample code of a laser pointer for object selection for the Oculus Touch Controllers

ClydeHuibregtse
Honored Guest
@oculus_gabor

Hey! I love the tutorial, and I am very close to replicating this with my own project. However, my current issue is that these rays are only hitting Non-UI elements. I can extract information from 3D objects the rays hit, but they seem to pass right through UI elements with no return. If this is a common issue please let me know what your thoughts are. I have scoured a ton of details looking for any asymmetries between our two projects and cant seem to find one.

Let me know.

oculus_gabor
Protege
@ClydeHuibregtse Hitting the UI is going to have to go trough a different system than hitting 3D objects (IE, not Physics.Raycast). The code presented in this post will do both: https://developer.oculus.com/blog/easy-controller-selection/

Hope that helps, let me know if it doesn't.

hamxa_ahmad_39
Honored Guest
I appreciate the Oculus staff helping out this much, but it'd b great if Oculus could proivde the relevant scripts with the Oculus integration asset provided in the asset store. I spent a week roaming here and there for answers, before I stumbled. The scripts provided here work like   a charm

OrangeCakeStudi
Honored Guest


Blog update is live: https://developer.oculus.com/blog/easy-controller-selection/


Hi, the link to the 3 rar files is broken..it says the files are corrupt?
EDIT: Ignor this..I just needed to extract all 3 rar files at once 🙂