t1 / TFDContents / Assets / KinectScripts / MultiScene / LoadLevelWhenUserDetected.cs @ 3
이력 | 보기 | 이력해설 | 다운로드 (1.47 KB)
| 1 |
using UnityEngine; |
|---|---|
| 2 |
using System.Collections; |
| 3 |
using UnityEngine.SceneManagement; |
| 4 |
|
| 5 |
public class LoadLevelWhenUserDetected : MonoBehaviour |
| 6 |
{
|
| 7 |
[Tooltip("User pose that will trigger the loading of next level.")]
|
| 8 |
public KinectGestures.Gestures expectedUserPose = KinectGestures.Gestures.None; |
| 9 |
|
| 10 |
[Tooltip("Next level number. No level is loaded, if the number is negative.")]
|
| 11 |
public int nextLevel = -1; |
| 12 |
|
| 13 |
[Tooltip("Whether to check for initialized KinectManager or not.")]
|
| 14 |
public bool validateKinectManager = true; |
| 15 |
|
| 16 |
[Tooltip("GUI-Text used to display the debug messages.")]
|
| 17 |
public GUIText debugText; |
| 18 |
|
| 19 |
|
| 20 |
private bool levelLoaded = false; |
| 21 |
private KinectGestures.Gestures savedCalibrationPose; |
| 22 |
|
| 23 |
|
| 24 |
void Start() |
| 25 |
{
|
| 26 |
KinectManager manager = KinectManager.Instance; |
| 27 |
|
| 28 |
if(validateKinectManager && debugText != null) |
| 29 |
{
|
| 30 |
if(manager == null || !manager.IsInitialized()) |
| 31 |
{
|
| 32 |
debugText.text = "KinectManager is not initialized!"; |
| 33 |
levelLoaded = true; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
if(manager != null && manager.IsInitialized()) |
| 38 |
{
|
| 39 |
savedCalibrationPose = manager.playerCalibrationPose; |
| 40 |
manager.playerCalibrationPose = expectedUserPose; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
void Update() |
| 46 |
{
|
| 47 |
if(!levelLoaded && nextLevel >= 0) |
| 48 |
{
|
| 49 |
KinectManager manager = KinectManager.Instance; |
| 50 |
|
| 51 |
if(manager != null && manager.IsUserDetected()) |
| 52 |
{
|
| 53 |
manager.playerCalibrationPose = savedCalibrationPose; |
| 54 |
|
| 55 |
levelLoaded = true; |
| 56 |
SceneManager.LoadScene(nextLevel); |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
} |