InteracitveNumber update validation on potential type change

This commit is contained in:
sinaioutlander 2020-11-17 02:51:20 +11:00
parent 8e2e2abef4
commit d379d6b129

View File

@ -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<InputField>();
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));