Remove editor validation and add error checking for the ColorLabel component

pull/413/head
Simon Jackson 2023-02-04 19:23:26 +00:00
parent 8d18515a4a
commit b59f5132c3
1 changed files with 4 additions and 12 deletions

View File

@ -34,6 +34,10 @@ namespace UnityEngine.UI.Extensions.ColorPicker
#else
label = GetComponent<Text>();
#endif
if (!label)
{
Debug.LogError($"{gameObject.name} does not have a Text component assigned for the {nameof(ColorLabel)}");
}
}
private void OnEnable()
@ -54,18 +58,6 @@ namespace UnityEngine.UI.Extensions.ColorPicker
}
}
#if UNITY_EDITOR
private void OnValidate()
{
#if UNITY_2022_1_OR_NEWER
label = GetComponent<TMPro.TMP_Text>();
#else
label = GetComponent<Text>();
#endif
UpdateValue();
}
#endif
private void ColorChanged(Color color)
{
UpdateValue();