using System; using UnityEngine; using UnityEngine.UI; namespace SpellBoundAR.MusicalInstruments.Piano { [DisallowMultipleComponent] [RequireComponent(typeof(Text))] public class PianoKeyLabel : MonoBehaviour { [SerializeField] private Color colorWhenColorsEnabled = Color.white; [SerializeField] private Color colorWhenColorsDisabled = Color.gray; [Header("Cache")] private Text _text; private void Awake() { _text = GetComponent(); } private void OnEnable() { MusicalInstrumentsManager.OnColorsChanged += Refresh; Refresh(); } private void OnDisable() { MusicalInstrumentsManager.OnColorsChanged += Refresh; } private void Refresh() { if (!_text) return; _text.color = MusicalInstrumentsManager.Colors ? colorWhenColorsEnabled : colorWhenColorsDisabled; } } }