forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapsLockHighlight.cs
More file actions
56 lines (49 loc) · 1.09 KB
/
CapsLockHighlight.cs
File metadata and controls
56 lines (49 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
using UnityEngine.UI;
namespace HoloToolkit.UI.Keyboard
{
public class CapsLockHighlight : MonoBehaviour
{
/// <summary>
/// The highlight image to turn on and off.
/// </summary>
[SerializeField]
private Image m_Highlight;
/// <summary>
/// The keyboard to check for caps locks
/// </summary>
private Keyboard m_Keyboard;
/// <summary>
/// Unity Start method.
/// </summary>
private void Start()
{
m_Keyboard = this.GetComponentInParent<Keyboard>();
UpdateState();
}
/// <summary>
/// Unity update method.
/// </summary>
private void Update()
{
UpdateState();
}
/// <summary>
/// Updates the visual state of the shift highlight.
/// </summary>
private void UpdateState()
{
bool isCapsLock = false;
if (m_Keyboard != null)
{
isCapsLock = m_Keyboard.IsCapsLocked;
}
if (m_Highlight != null)
{
m_Highlight.enabled = isCapsLock;
}
}
}
}