From 196435721cd0de5dafaaf431f97c9e270e765948 Mon Sep 17 00:00:00 2001 From: Eric Heine <erheine@nps.edu> Date: Wed, 31 Jul 2019 11:36:08 -0700 Subject: [PATCH] Tweaked the float variable input so you're actually able to type in decimal values. --- .../Scriptable Variables/FloatVariableInput.cs | 11 ++++++++--- package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Sane Eric's UI/Scriptable Variables/FloatVariableInput.cs b/Sane Eric's UI/Scriptable Variables/FloatVariableInput.cs index 0882dff..53e0112 100644 --- a/Sane Eric's UI/Scriptable Variables/FloatVariableInput.cs +++ b/Sane Eric's UI/Scriptable Variables/FloatVariableInput.cs @@ -27,7 +27,12 @@ namespace Shared.SEUI { protected override void AddUIListener(UnityAction<float> callback) { // Define the value converting bridge callback to add to the UI listener valueConverter = delegate(string value) { - callback(Convert.ToSingle(value)); + if (!String.IsNullOrEmpty(input.text)) { + callback(Convert.ToSingle(value)); + } + else { + callback(0.0f); + } }; input.onValueChanged.AddListener(valueConverter); @@ -43,12 +48,12 @@ namespace Shared.SEUI { //--------------------------------------------------------------------------- protected override bool DoValuesMatch() { - return input.text == variable.Value.ToString(); + return !String.IsNullOrEmpty(input.text) && Convert.ToSingle(input.text) == variable.Value; } //--------------------------------------------------------------------------- protected override void UpdateUIValue() { - input.text = variable.Value.ToString(); + input.SetTextWithoutNotify(variable.Value.ToString()); } //--------------------------------------------------------------------------- diff --git a/package.json b/package.json index 80847a3..b9f68dd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.futuretech.shared", "displayName": "FutureTech Shared", "description": "Contains shared items such as the Scriptable Variables.", - "version": "0.1.14", + "version": "0.1.15", "unity": "2018.3", "license": "MIT", "repository": { -- GitLab