Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
RealMVC's avatar
RealMVC
Honored Guest
8 years ago

OVRTouchpad.TouchHandler doesn't exist.

I am using Unity 2018.1.1f1, and I have imported the latest Unity_Sample_Framework and Oculus Utilities.
I am running Windows 10.
Here is my code:

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

public class Teleporter : MonoBehaviour {

    public GameObject TeleportMarker;
    public Transform Player;
    public float Raylength = 50f;


    void Start()
    {
        OVRTouchpad.Create();
        OVRTouchpad.TouchHandler += TouchpadHandler;
    }

    void Update()
    {
        Ray ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;
        if(Physics.Raycast(ray, out hit, Raylength))
        {
            if(hit.collider.tag == "floor")
            {
                if (!TeleportMarker.activeSelf)
                {
                    TeleportMarker.SetActive(true);
                }
                TeleportMarker.transform.position = hit.point;
            }
        }
    }

    void TouchpadHandler(object sender, System.EventArgs e)
    {
        OVRTouchpad.TouchArgs args = (OVRTouchpad.TouchArgs)e;
        if(args.TouchType == OVRTouchpad.TouchEvent.SingleTap)
        {

        }
    }
}

For some reason, OVRTouchpad.TouchArgs and OVRTouchpad.TouchHandler don't exist.
Can someone help me with this?

2 Replies

Replies have been turned off for this discussion
  • Probably, this was solved, but truth is you should not use TouchHandler, you should use OVRTouchpad.AddListener instead... like

    OVRTouchpad.AddListener(LocalTouchEventCallback);

            private void LocalTouchEventCallback(OVRTouchpad.TouchEvent button)
            {
                    switch(touchEvent)
                    {
                            case(OVRTouchpad.TouchEvent.SingleTap):
                            // Do some stuff
                            break;
                            case(OVRTouchpad.TouchEvent.DoubleTap):
                            // Do some stuff
                            break;
                            .
                            .
                            .
                    }
            }
  • Probably, this was solved, but truth is you should not use TouchHandler, you should use OVRTouchpad.AddListener instead... like

    OVRTouchpad.AddListener(LocalTouchEventCallback);

            private void LocalTouchEventCallback(OVRTouchpad.TouchEvent button)
            {
                    switch(touchEvent)
                    {
                            case(OVRTouchpad.TouchEvent.SingleTap):
                            // Do some stuff
                            break;
                            case(OVRTouchpad.TouchEvent.DoubleTap):
                            // Do some stuff
                            break;
                            .
                            .
                            .
                    }
            }