-
Notifications
You must be signed in to change notification settings - Fork 0
/
blinkDetection.cs
64 lines (51 loc) · 1.39 KB
/
blinkDetection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using UnityEngine;
using UnityEditor;
using Fove.Managed;
using System;
using FoveGCD = UnityEngine.FoveInterfaceBase.GazeConvergenceData;
public class blinkDetection : MonoBehaviour
{
EFVR_Eye myEyeStruct;
string prev = "";
FoveGCD prevgcd;
FoveGCD gcd;
RaycastHit hit;
static int blinkCounter = 0;
public delegate void myFunc();
private void Start()
{
}
private void Update()
{
RaycastHit hit;
myEyeStruct = FoveInterface.CheckEyesClosed();
gcd = FoveInterface.GetGazeConvergence();
if (!prevgcd.Equals(gcd) || prev == "")
{
Physics.Raycast(gcd.ray, out hit, Mathf.Infinity);
transform.position = hit.point;
prevgcd = gcd;
//Debug.Log("(accuracy,distance,ray) " + gcd.accuracy + " " + gcd.distance + " " + gcd.ray);
}
if (prev == "" || prev != myEyeStruct.ToString())
{
prev = myEyeStruct.ToString();
//Debug.Log(prev);
}
}
void BlinkCounter(myFunc variable) {
if (blinkCounter == 2)
{
//doing what u want
variable();
}
else if (blinkCounter <= 3)
{
blinkCounter++;
}
else
{
blinkCounter = 0;
}
}
}