From d379d6b129b2ddac7770a5da3039775a5c43ded7 Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Tue, 17 Nov 2020 02:51:20 +1100 Subject: [PATCH] InteracitveNumber update validation on potential type change --- .../InteractiveValue/InteractiveNumber.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Inspectors/Reflection/InteractiveValue/InteractiveNumber.cs b/src/Inspectors/Reflection/InteractiveValue/InteractiveNumber.cs index 3e2818c..2c58907 100644 --- a/src/Inspectors/Reflection/InteractiveValue/InteractiveNumber.cs +++ b/src/Inspectors/Reflection/InteractiveValue/InteractiveNumber.cs @@ -49,6 +49,18 @@ namespace UnityExplorer.Inspectors.Reflection m_baseLabel.text = UISyntaxHighlight.ParseFullSyntax(FallbackType, false); m_valueInput.text = Value.ToString(); + var type = Value.GetType(); + if (type == typeof(float) + || type == typeof(double) + || type == typeof(decimal)) + { + m_valueInput.characterValidation = InputField.CharacterValidation.Decimal; + } + else + { + m_valueInput.characterValidation = InputField.CharacterValidation.Integer; + } + if (Owner.CanWrite) { if (!m_applyBtn.gameObject.activeSelf) @@ -96,17 +108,6 @@ namespace UnityExplorer.Inspectors.Reflection m_valueInput = inputObj.GetComponent(); m_valueInput.gameObject.SetActive(false); - if (this.FallbackType == typeof(float) - || this.FallbackType == typeof(double) - || this.FallbackType == typeof(decimal)) - { - m_valueInput.characterValidation = InputField.CharacterValidation.Decimal; - } - else - { - m_valueInput.characterValidation = InputField.CharacterValidation.Integer; - } - if (Owner.CanWrite) { var applyBtnObj = UIFactory.CreateButton(m_valueContent, new Color(0.2f, 0.2f, 0.2f));