Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
sh0v0r's avatar
sh0v0r
Protege
9 years ago

Gaze Pointers & Drop Down Boxes

When I use a Drop Down box the Gaze Pointer disappears as it hovers over the items, is this a known issue?

6 Replies

Replies have been turned off for this discussion
  • I think I've tracked it down to the OVRInputModule.GetGazePointerData

    OVRRaycaster ovrRaycaster = raycast.module as OVRRaycaster;
     
    overRaycaster is Null, I wonder if this has anything to do with the fact the DropList doesn't exist until it is dropped down?
  • OK, worked it out, the DropdownList GameObject that is created when the list is dropped down contains its own Canvas... I'll see if I can add the OVRRaycaster Component when it is instantiated...
  • Actually I'm a bit lost here on how best to tackle this, any help would be greatly appreciated...
  • I may continue to look for a better way, but for now my dropdown menus are working in VR when I add this to the UI script:






        // HACK for selecting dropdowns in vr

        private void Update() {

            if (XRSettings.isDeviceActive) {

                var found = gameObject.GetComponentsInChildren<GraphicRaycaster>();

                foreach (var gr in found) {

                    var ovr = gr.GetComponent<OVRRaycaster>();

                    if (ovr == null) {

                        gr.enabled = false;

                        ovr = gr.gameObject.AddComponent<OVRRaycaster>();

                        ovr.sortOrder = 20;

                    }

                }

            }

        }
      

    Basically, the idea is to look for GraphicRaycaster components (which are on the dropdown canvases) and replace with OVRRaycaster.
  • OCReaper's avatar
    OCReaper
    Honored Guest
    What you can do is add this script to your Template inside your Dropdown 
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;

    public class CanvasVRModifier : MonoBehaviour
    {
    public GameObject pointer;
    private void Awake()
    {
    GraphicRaycaster gr = GetComponent<GraphicRaycaster>();
    OVRRaycaster OVRrc = null;
    if (gr != null)
    {
    gr.enabled = false;
    OVRrc = gameObject.AddComponent<OVRRaycaster>();
    OVRrc.pointer = pointer;
    OVRrc.blockingObjects = OVRRaycaster.BlockingObjects.All;
    }
    }
    }