t1 / TFDContents / Assets / KinectDemos / SpeechRecognitionDemo / Scripts / GameControlScript.cs @ 3
이력 | 보기 | 이력해설 | 다운로드 (2.16 KB)
1 |
using UnityEngine; |
---|---|
2 |
using System.Collections; |
3 |
|
4 |
public class GameControlScript : MonoBehaviour |
5 |
{ |
6 |
[Tooltip("Prefab used to create the scene fence.")] |
7 |
public GameObject cratePrefab; |
8 |
|
9 |
[Tooltip("GUI-Window rectangle in screen coordinates (pixels).")] |
10 |
public Rect guiWindowRect = new Rect(10, 40, 200, 300); |
11 |
|
12 |
[Tooltip("GUI-Window skin (optional).")] |
13 |
public GUISkin guiSkin; |
14 |
|
15 |
|
16 |
// whether the fence is already created |
17 |
private bool isFenceCreated = false; |
18 |
|
19 |
|
20 |
void Update () |
21 |
{ |
22 |
if(!isFenceCreated) |
23 |
{ |
24 |
SpeechManager speechManager = SpeechManager.Instance; |
25 |
|
26 |
if(speechManager && speechManager.IsSapiInitialized()) |
27 |
{ |
28 |
Quaternion quatRot90 = Quaternion.Euler(new Vector3(0, 90, 0)); |
29 |
GameObject newObj = null; |
30 |
|
31 |
for(int i = -50; i <= 50; i++) |
32 |
{ |
33 |
newObj = (GameObject)GameObject.Instantiate(cratePrefab, new Vector3(i, 0.32f, 50), Quaternion.identity); |
34 |
newObj.transform.parent = transform; |
35 |
|
36 |
newObj = (GameObject)GameObject.Instantiate(cratePrefab, new Vector3(i, 0.32f, -50), Quaternion.identity); |
37 |
newObj.transform.parent = transform; |
38 |
|
39 |
newObj = (GameObject)GameObject.Instantiate(cratePrefab, new Vector3(50, 0.32f, i), quatRot90); |
40 |
newObj.transform.parent = transform; |
41 |
|
42 |
newObj = (GameObject)GameObject.Instantiate(cratePrefab, new Vector3(-50, 0.32f, i), quatRot90); |
43 |
newObj.transform.parent = transform; |
44 |
} |
45 |
|
46 |
isFenceCreated = true; |
47 |
} |
48 |
} |
49 |
} |
50 |
|
51 |
private void ShowGuiWindow(int windowID) |
52 |
{ |
53 |
GUILayout.BeginVertical(); |
54 |
|
55 |
GUILayout.Label(""); |
56 |
GUILayout.Label("<b>* FORWARD / GO AHEAD</b>"); |
57 |
GUILayout.Label("<b>* BACK / GO BACK</b>"); |
58 |
GUILayout.Label("<b>* TURN LEFT</b>"); |
59 |
GUILayout.Label("<b>* TURN RIGHT</b>"); |
60 |
GUILayout.Label("<b>* RUN</b>"); |
61 |
GUILayout.Label("<b>* JUMP</b>"); |
62 |
GUILayout.Label("<b>* STOP</b>"); |
63 |
GUILayout.Label("<b>* HELLO / WAVE</b>"); |
64 |
GUILayout.Label("<i>For more audio commands\nlook at the grammar file.</i>"); |
65 |
|
66 |
GUILayout.EndVertical(); |
67 |
|
68 |
// Make the window draggable. |
69 |
GUI.DragWindow(); |
70 |
} |
71 |
|
72 |
void OnGUI() |
73 |
{ |
74 |
GUI.skin = guiSkin; |
75 |
guiWindowRect = GUI.Window(0, guiWindowRect, ShowGuiWindow, "Audio Commands"); |
76 |
} |
77 |
|
78 |
} |