Created
January 31, 2017 22:35
-
-
Save flushpot1125/19ebea20cafa1c0e94a3d06ea94de766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*copied from complete version in sample project of "https://developer.microsoft.com/en-us/windows/holographic/holograms_210"*/ | |
using UnityEngine; | |
namespace Academy.HoloToolkit.Unity | |
{ | |
/// <summary> | |
/// CursorManager class takes Cursor GameObjects. | |
/// One that is on Holograms and another off Holograms. | |
/// Shows the appropriate Cursor when a Hologram is hit. | |
/// Places the appropriate Cursor at the hit position. | |
/// Matches the Cursor normal to the hit surface. | |
/// </summary> | |
public class CursorManager : Singleton<CursorManager> | |
{ | |
[Tooltip("Drag the Cursor object to show when it hits a hologram.")] | |
public GameObject CursorOnHolograms; | |
[Tooltip("Drag the Cursor object to show when it does not hit a hologram.")] | |
public GameObject CursorOffHolograms; | |
void Awake() | |
{ | |
if (CursorOnHolograms == null || CursorOffHolograms == null) | |
{ | |
return; | |
} | |
// Hide the Cursors to begin with. | |
CursorOnHolograms.SetActive(false); | |
CursorOffHolograms.SetActive(false); | |
} | |
void Update() | |
{ | |
/* TODO: DEVELOPER CODING EXERCISE 2.b */ | |
if (GazeManager.Instance == null || CursorOnHolograms == null || CursorOffHolograms == null) | |
{ | |
return; | |
} | |
if (GazeManager.Instance.Hit) | |
{ | |
// 2.b: SetActive true the CursorOnHolograms to show cursor. | |
CursorOnHolograms.SetActive(true); | |
// 2.b: SetActive false the CursorOffHolograms hide cursor. | |
CursorOffHolograms.SetActive(false); | |
} | |
else | |
{ | |
// 2.b: SetActive true CursorOffHolograms to show cursor. | |
CursorOffHolograms.SetActive(true); | |
// 2.b: SetActive false CursorOnHolograms to hide cursor. | |
CursorOnHolograms.SetActive(false); | |
} | |
// 2.b: Assign gameObject's transform position equals GazeManager's instance Position. | |
gameObject.transform.position = GazeManager.Instance.Position; | |
// 2.b: Assign gameObject's transform up vector equals GazeManager's instance Normal. | |
gameObject.transform.up = GazeManager.Instance.Normal; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment