// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using UnityEngine; using UnityEngine.UI; namespace Microsoft.MixedReality.Toolkit.Experimental.UI { /// /// This class toggles the Caps Lock image based on the NonNativeKeyboard's IsCapsLocked state /// public class CapsLockHighlight : MonoBehaviour { /// /// The highlight image to turn on and off. /// [Experimental] [SerializeField] private Image m_Highlight = null; /// /// The keyboard to check for caps locks /// private NonNativeKeyboard m_Keyboard; /// /// Unity Start method. /// private void Start() { m_Keyboard = GetComponentInParent(); UpdateState(); } /// /// Unity update method. /// private void Update() { UpdateState(); } /// /// Updates the visual state of the shift highlight. /// private void UpdateState() { bool isCapsLock = false; if (m_Keyboard != null) { isCapsLock = m_Keyboard.IsCapsLocked; } if (m_Highlight != null) { m_Highlight.enabled = isCapsLock; } } } }