From b59f5132c3dd85c2e1d2999652f1d0be0d0d2a77 Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Sat, 4 Feb 2023 19:23:26 +0000 Subject: [PATCH] Remove editor validation and add error checking for the ColorLabel component --- .../Scripts/Controls/ColorPicker/ColorLabel.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Runtime/Scripts/Controls/ColorPicker/ColorLabel.cs b/Runtime/Scripts/Controls/ColorPicker/ColorLabel.cs index 74d156e..5582ca8 100644 --- a/Runtime/Scripts/Controls/ColorPicker/ColorLabel.cs +++ b/Runtime/Scripts/Controls/ColorPicker/ColorLabel.cs @@ -34,6 +34,10 @@ namespace UnityEngine.UI.Extensions.ColorPicker #else label = GetComponent(); #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(); -#else - label = GetComponent(); -#endif - UpdateValue(); - } -#endif - private void ColorChanged(Color color) { UpdateValue();