AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ObjectCursor.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using System;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.InputModule
8 {
13  public class ObjectCursor : Cursor
14  {
15  [Serializable]
16  public struct ObjectCursorDatum
17  {
18  public string Name;
20  public GameObject CursorObject;
21  }
22 
23  [SerializeField]
25 
29  public Transform ParentTransform;
30 
34  protected override void OnEnable()
35  {
36  if(ParentTransform == null)
37  {
38  ParentTransform = transform;
39  }
40  base.OnEnable();
41  }
42 
48  public override void OnCursorStateChange(CursorStateEnum state)
49  {
50  base.OnCursorStateChange(state);
51 
52  if (state != CursorStateEnum.Contextual)
53  {
54  // Hide all children first
55  for(int i = 0; i < ParentTransform.childCount; i++)
56  {
57  ParentTransform.GetChild(i).gameObject.SetActive(false);
58  }
59 
60  // Set active any that match the current state
61  for (int i = 0; i < CursorStateData.Length; i++)
62  {
63  if (CursorStateData[i].CursorState == state)
64  {
65  CursorStateData[i].CursorObject.SetActive(true);
66  }
67  }
68  }
69  }
70  }
71 }
Transform ParentTransform
Sprite renderer to change. If null find one in children
Definition: ObjectCursor.cs:29
override void OnCursorStateChange(CursorStateEnum state)
Override OnCursorState change to set the correct animation state for the cursor
Definition: ObjectCursor.cs:48
CursorStateEnum
Enum for current cursor state
The object cursor can switch between different game objects based on its state. It simply links the g...
Definition: ObjectCursor.cs:13
override void OnEnable()
On enable look for a sprite renderer on children
Definition: ObjectCursor.cs:34