-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelectCamera.cs
144 lines (112 loc) · 3.09 KB
/
SelectCamera.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
Script: SelectCamera
Author: Alex MacNair
Function: Used to switch the viewpoint between cameras by enabling / disabling
each camera. Camera 1 the default
starting camera.
Usage: This script should be applied to a single object in the scene. The
Main Camera is suggested. Each of the four audience perspective
cameras must be specified in the inspector pane.
The function keys f1-f4 are used to select the active camera.
*/
using UnityEngine;
using System.Collections;
public class SelectCamera : MonoBehaviour {
public GameObject camText1;
public GameObject camText2;
public GameObject camText3;
public GameObject camText4;
public Camera camera1;
public Camera camera2;
public Camera camera3;
public Camera camera4;
private int deltaFrames = 0;
private bool helpTextEnabled = false;
private bool debugModeEnabled = false;
private GameObject[] tokens; //Stores a list of every token in the scene
// Use this for initialization
void Start () {
camera1.enabled = true;
camera2.enabled = false;
camera3.enabled = false;
camera4.enabled = false;
camText1.SetActive(false);
camText2.SetActive(false);
camText3.SetActive(false);
camText4.SetActive(false);
helpTextEnabled = false;
}
// Update is called once per frame
void Update () {
++deltaFrames;
if (Input.GetKey("c") && (deltaFrames > 8)) {
Debug.Log("Enabing help text");
if (helpTextEnabled == false) {
camText1.SetActive(true);
camText2.SetActive(true);
camText3.SetActive(true);
camText4.SetActive(true);
helpTextEnabled = true;
deltaFrames = 0;
}
else {
camText1.SetActive(false);
camText2.SetActive(false);
camText3.SetActive(false);
camText4.SetActive(false);
helpTextEnabled = false;
deltaFrames = 0;
}
}
if (Input.GetKey("d")) {
if (!debugModeEnabled) {
Debug.Log("Enabling debug mode!");
tokens = GameObject.FindGameObjectsWithTag("Token"); //Populate array with all token objects
foreach (GameObject token in tokens) {
token.GetComponent<MeshRenderer>().enabled = true;
}
debugModeEnabled = true;
}
else {
Debug.Log("Disabling debug mode!");
tokens = GameObject.FindGameObjectsWithTag("Token"); //Populate array with all token objects
foreach (GameObject token in tokens) {
token.GetComponent<MeshRenderer>().enabled = false;
}
debugModeEnabled = false;
}
}
if (Input.GetKey("1"))
{
Debug.Log("Camera 1 Active");
camera1.enabled = true;
camera2.enabled = false;
camera3.enabled = false;
camera4.enabled = false;
}
if (Input.GetKey("2"))
{
Debug.Log("Camera 2 Active");
camera2.enabled = true;
camera1.enabled = false;
camera3.enabled = false;
camera4.enabled = false;
}
if (Input.GetKey("3"))
{
Debug.Log("Camera 3 Active");
camera3.enabled = true;
camera1.enabled = false;
camera2.enabled = false;
camera4.enabled = false;
}
if (Input.GetKey("4"))
{
Debug.Log("Camera 4 Active");
camera4.enabled = true;
camera1.enabled = false;
camera2.enabled = false;
camera3.enabled = false;
}
}
}