forked from tanus786/CP-Codes-HackOctober-Fest-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GazeButton.cs
40 lines (36 loc) · 822 Bytes
/
GazeButton.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class GazeButton : MonoBehaviour
{
public Image imgCircle;
public UnityEvent GVRClick;
public float totalTime = 2;
bool gvrStatus;
public float gvrTimer;
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
if (gvrStatus)
{
gvrTimer += Time.deltaTime;
imgCircle.fillAmount = gvrTimer / totalTime;
}
if(gvrTimer > totalTime)
{
GVRClick.Invoke();
}
}
public void GvrOn()
{
gvrStatus = true;
}
public void GvrOff()
{
gvrStatus = false;
gvrTimer = 0;
}
}