Forum Discussion
RealMVC
8 years agoHonored Guest
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)
{
}
}
}
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
- LordRyuuzaHonored GuestProbably, 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;
.
.
.
}} - LordRyuuzaHonored GuestProbably, 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;
.
.
.
}}
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device