- Home /
How to Detect Swipes using the VRInput Script
Hi - I am new to Unity and trying to modify the [Unity tutorial Interactive 360 Sample][1]. I want to be able to call a function when a user swipes using an Oculus Go Controller. I noticed that the InputVR script is included in the project, which seems to be able to detect swipe gestures. But where do I attach that script, and how do I subscribe to the OnSwipe event.
I am currently trying by making an empty game object, and attaching the InputVR script as well as my own script called "GestureHandler" (I'm not sure whether InputVR is already attached to something else in the sample project, or whether I need to attach it at all). In my GestureHandler script I currently have the following:
using System.Collections;
using System.Collections.Generic;
using Interactive360.Utils;
using UnityEngine;
public class GestureHandler : MonoBehaviour {
void onEnable(){
VRInput.OnSwipe += HandleSwipe;
}
void onDisable(){
VRInput.OnSwipe -= HandleSwipe;
}
void HandleSwipe(){
Debug.Log("swipe");
}
}
and currently have the following errors:
An object reference is required for the non-static field, method, or property 'VRInput.OnSwipe' [Assembly-CSharp]
No overload for 'HandleSwipe' matches delegate 'Action<VRInput.SwipeDirection>' [Assembly-CSharp]
An object reference is required for the non-static field, method, or property 'VRInput.OnSwipe' [Assembly-CSharp]
No overload for 'HandleSwipe' matches delegate 'Action<VRInput.SwipeDirection>' [Assembly-CSharp]
[1]: https://assetstore.unity.com/packages/essentials/tutorial-projects/interactive-360-sample-project-108974
[2]: https://unity3d.com/learn/tutorials/topics/virtual-reality/interaction-vr
[3]: https://i.imgur.com/oUh1nQq.png