AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ButtonFocusShowHideWidget.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.Collections;
5 using System.Collections.Generic;
6 using UnityEngine;
7 
8 namespace HoloToolkit.Examples.InteractiveElements
9 {
14  {
15  [Tooltip("Array of gameObjects to turn on and off during focus")]
16  public GameObject[] Targets;
17 
18  private bool SelfHosted = false;
19  private void Awake()
20  {
21  if (Targets.Length == 0)
22  {
23  Targets = new GameObject[1] { this.gameObject };
24  SelfHosted = true;
25  }
26  }
27 
28  protected override void OnDisable()
29  {
30  // ignore if we are the only object in the list
31  if (!SelfHosted)
32  {
33  base.OnDisable();
34  }
35  }
36 
41  public override void SetState(Interactive.ButtonStateEnum state)
42  {
43  base.SetState(state);
44  bool show = (state == Interactive.ButtonStateEnum.FocusSelected || state == Interactive.ButtonStateEnum.Focus || state == Interactive.ButtonStateEnum.Press || state == Interactive.ButtonStateEnum.PressSelected);
45 
46  for (int i = 0; i < Targets.Length; ++i)
47  {
48  Targets[i].SetActive(show);
49  }
50  }
51  }
52 }
InteractiveState can exist on a child element of the game object containing the Interactive component...
override void SetState(Interactive.ButtonStateEnum state)
Set active state
ButtonStateEnum
A button typically has 8 potential states. We can update visual feedback based on state change...
Definition: Interactive.cs:80
Set an elements activity (true/false) based on Interactive focus state
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22