Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit d379d6b

Browse files
committed
InteracitveNumber update validation on potential type change
1 parent 8e2e2ab commit d379d6b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/Inspectors/Reflection/InteractiveValue/InteractiveNumber.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ public override void RefreshUIForValue()
4949
m_baseLabel.text = UISyntaxHighlight.ParseFullSyntax(FallbackType, false);
5050
m_valueInput.text = Value.ToString();
5151

52+
var type = Value.GetType();
53+
if (type == typeof(float)
54+
|| type == typeof(double)
55+
|| type == typeof(decimal))
56+
{
57+
m_valueInput.characterValidation = InputField.CharacterValidation.Decimal;
58+
}
59+
else
60+
{
61+
m_valueInput.characterValidation = InputField.CharacterValidation.Integer;
62+
}
63+
5264
if (Owner.CanWrite)
5365
{
5466
if (!m_applyBtn.gameObject.activeSelf)
@@ -96,17 +108,6 @@ public override void ConstructUI(GameObject parent, GameObject subGroup)
96108
m_valueInput = inputObj.GetComponent<InputField>();
97109
m_valueInput.gameObject.SetActive(false);
98110

99-
if (this.FallbackType == typeof(float)
100-
|| this.FallbackType == typeof(double)
101-
|| this.FallbackType == typeof(decimal))
102-
{
103-
m_valueInput.characterValidation = InputField.CharacterValidation.Decimal;
104-
}
105-
else
106-
{
107-
m_valueInput.characterValidation = InputField.CharacterValidation.Integer;
108-
}
109-
110111
if (Owner.CanWrite)
111112
{
112113
var applyBtnObj = UIFactory.CreateButton(m_valueContent, new Color(0.2f, 0.2f, 0.2f));

0 commit comments

Comments
 (0)