-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuOptionController.cs
More file actions
executable file
·66 lines (50 loc) · 1.52 KB
/
MenuOptionController.cs
File metadata and controls
executable file
·66 lines (50 loc) · 1.52 KB
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
65
66
using UnityEngine;
using System.Collections;
using UnityEngine.VR;
using UnityEngine.SceneManagement;
public class MenuOptionController : MonoBehaviour, IGvrGazeResponder {
bool isLooking;
float optionTimer = 0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (isLooking) {
optionTimer += Time.deltaTime;
if (this.gameObject.transform.position.x > 2.5) {
this.gameObject.transform.position -= this.gameObject.transform.forward * 0.2f;
}
if (optionTimer > 2.0f)
{
LoadLevel ();
}
} else {
optionTimer = 0;
if (this.gameObject.transform.position.x < 4)
{
this.gameObject.transform.position += this.gameObject.transform.forward*0.2f;
}
}
}
void LoadLevel ()
{
// float fadeTime = GameObject.FindGameObjectWithTag ("SceneController").GetComponent <Fader> ().BeginFade(1);
// yield return new WaitForSeconds (1);
SceneManager.LoadScene("PrimaryScene");
}
/// Called when the user is looking on a GameObject with this script,
/// as long as it is set to an appropriate layer (see GvrGaze).
public void OnGazeEnter() {
isLooking = true;
}
/// Called when the user stops looking on the GameObject, after OnGazeEnter
/// was already called.
public void OnGazeExit() {
isLooking = false;
}
/// Called when the viewer's trigger is used, between OnGazeEnter and OnGazeExit.
/// If the Cardboard viewer is triggered while looking at the backdrop, rotate the active/falling block
public void OnGazeTrigger() {
}
}