AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SymbolDisableHighlight.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 UnityEngine;
5 using UnityEngine.UI;
6 
7 namespace HoloToolkit.UI.Keyboard
8 {
9  public class SymbolDisableHighlight : MonoBehaviour
10  {
14  [SerializeField]
15  private Text m_TextField = null;
16 
20  [SerializeField]
21  private Image m_ImageField = null;
22 
26  [SerializeField]
27  private Color m_DisabledColor = Color.grey;
28 
32  private Color m_StartingColor = Color.white;
33 
37  private Button m_Button = null;
38 
42  private void Start()
43  {
44  if (m_TextField != null)
45  {
46  m_StartingColor = m_TextField.color;
47  }
48 
49  if (m_ImageField != null)
50  {
51  m_StartingColor = m_ImageField.color;
52  }
53 
54  m_Button = GetComponentInParent<Button>();
55 
56  UpdateState();
57  }
58 
62  private void Update()
63  {
64  UpdateState();
65  }
66 
70  private void UpdateState()
71  {
72  if (m_TextField != null && m_Button != null)
73  {
74  m_TextField.color = m_Button.interactable ? m_StartingColor : m_DisabledColor;
75  }
76 
77  if (m_ImageField != null && m_Button != null)
78  {
79  m_ImageField.color = m_Button.interactable ? m_StartingColor : m_DisabledColor;
80  }
81  }
82  }
83 }