-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToVirtualSceneryAndBack.cs
167 lines (151 loc) · 4.61 KB
/
ToVirtualSceneryAndBack.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToVirtualSceneryAndBack : MonoBehaviour {
public GameObject MainCam;
public GameObject ShowroomButtons;
public Text DescriptionCanvas1;
public Text DescriptionCanvas2;
public GameObject ExteriorCanvas;
public GameObject Door;
static bool Interior;
static bool Moved;
public Vector3 movedPosition;
public Quaternion movedRotation;
public int Speed;
private int maxSpeed;
private int minSpeed;
public Camera MainCamCam;
//private bool Captured;
// find the camera and lens that was chosen, and then put their settings here
// Use this for initialization
void Start () {
Interior = true;
Moved = false;
Speed = 1;
maxSpeed = 7;
minSpeed = 1;
MainCamCam = MainCam.GetComponent<Camera>();
//Captured = false;
}
// Update is called once per frame
void Update () {
// switch from inside to outside of room
if (Input.GetKeyDown(KeyCode.D) && Door.activeSelf) {
if (Interior) {
if (!Moved) {
MainCam.transform.position = new Vector3 (0, 10, 50);
MainCam.transform.rotation = Quaternion.Euler(new Vector3 (0, 0, 0));
} else {
MainCam.transform.position = movedPosition;
MainCam.transform.rotation = movedRotation;
}
Interior = false;
ShowroomButtons.SetActive (false);
ExteriorCanvas.SetActive (false);
DescriptionCanvas1.color = Color.white;
DescriptionCanvas2.color = Color.white;
} else {
MainCam.transform.position = new Vector3 (0, 19, -15);
MainCam.transform.rotation = Quaternion.Euler(new Vector3 (30, 0, 0));
Interior = true;
ShowroomButtons.SetActive (true);
ExteriorCanvas.SetActive (true);
DescriptionCanvas1.color = Color.black;
DescriptionCanvas2.color = Color.black;
}
}
// movement of camera
if (Input.GetKey (KeyCode.LeftArrow) && !Interior) {
MainCam.transform.Rotate (new Vector3 (0, -1, 0) * Speed);
movedPosition = MainCam.transform.position;
movedRotation = MainCam.transform.rotation;
Moved = true;
}
if (Input.GetKey (KeyCode.RightArrow) && !Interior) {
MainCam.transform.Rotate (new Vector3 (0, 1, 0) * Speed);
movedPosition = MainCam.transform.position;
movedRotation = MainCam.transform.rotation;
Moved = true;
}
if (Input.GetKey (KeyCode.UpArrow) && !Interior) {
if (MainCam.transform.position.z <= 30) {
MainCam.transform.position = new Vector3 (0, 10, 50);
} else {
MainCam.transform.Translate (new Vector3 (0, 0, 1) * Speed);
}
movedPosition = MainCam.transform.position;
movedRotation = MainCam.transform.rotation;
Moved = true;
}
if (Input.GetKey (KeyCode.DownArrow) && !Interior) {
if (MainCam.transform.position.z <= 30) {
MainCam.transform.position = new Vector3 (0, 10, 50);
} else {
MainCam.transform.Translate (new Vector3 (0, 0, -1) * Speed);
}
movedPosition = MainCam.transform.position;
movedRotation = MainCam.transform.rotation;
Moved = true;
}
// speed up or slow down motion of camera
if (Input.GetKey (KeyCode.Period) && !Interior) {
if (Speed <= maxSpeed) {
Speed += 1;
if (Speed > maxSpeed) {
Speed = maxSpeed;
}
} else {
Speed = maxSpeed;
}
}
if (Input.GetKey (KeyCode.Comma) && !Interior) {
if (Speed >= minSpeed) {
Speed -= 1;
if (Speed < minSpeed) {
Speed = minSpeed;
}
} else {
Speed = minSpeed;
}
}
//take picture
if (Input.GetKey (KeyCode.Space) && !Interior) {
Application.CaptureScreenshot (Application.dataPath + "/" + "screenshot" + Time.time.ToString() + ".png");
//Captured = true;
}
//reset camera position
if (Input.GetKey (KeyCode.R) && !Interior) {
Moved = false;
MainCam.transform.position = new Vector3 (0, 10, 50);
MainCam.transform.rotation = Quaternion.Euler(new Vector3 (0, 0, 0));
}
// zoom in and zoom out effect
if (Input.GetKey (KeyCode.F) && Interior) {
ShowroomButtons.SetActive (false);
ExteriorCanvas.SetActive (false);
MainCamCam.fieldOfView -= 1;
if (MainCamCam.fieldOfView < 20) {
MainCamCam.fieldOfView = 20;
}
}
if (Input.GetKey (KeyCode.G) && Interior) {
MainCamCam.fieldOfView += 1;
if (MainCamCam.fieldOfView > 60) {
MainCamCam.fieldOfView = 60;
ShowroomButtons.SetActive (true);
ExteriorCanvas.SetActive (true);
}
}
/*
// look at all pictures taken
if (Input.GetKey (KeyCode.P) && Captured) {
string[] files = System.IO.Directory.GetFiles(Application.dataPath, "screenshot*.png");
// display in console the paths of the screenshots
for (int c = 0; c < files.Length; c++) {
Debug.Log (files [c]);
}
}*/
}
}