Skip to content

Commit 22b5a31

Browse files
committed
Fix #28 : allow typing decimals into TAA parameter fields
1 parent 43d8203 commit 22b5a31

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Source/GUI/ConfigurationGUI.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class ConfigurationGUI : MonoBehaviour
2727

2828
/// <summary>
2929
/// Cached dictionaries of temporary variables used by the UI for user-input values.
30+
/// These are necessary because IMGUI is stateless; otherwise it is difficult for a user to type a number
31+
/// with a decimal since a roundtrip through Parse and ToString will remove it
3032
/// </summary>
3133
private Dictionary<string, string> propertyStringStorage = new Dictionary<string, string>();
3234
private Dictionary<string, float> propertyFloatStorage = new Dictionary<string, float>();
@@ -804,11 +806,22 @@ private void AddFloatField(string label, ref float value, float min, float max)
804806
GUILayout.BeginHorizontal();
805807
GUILayout.Label(label, GUILayout.Width(200), GUILayout.Height(22));
806808

807-
string oldValue = value.ToString();
808-
string newValue = GUILayout.TextArea(oldValue, GUILayout.Width(110));
809-
if (newValue != oldValue)
809+
if (propertyStringStorage.ContainsKey(label))
810810
{
811-
float.TryParse(newValue, out value);
811+
string oldValue = propertyStringStorage[label];
812+
string newValue = GUILayout.TextArea(oldValue, GUILayout.Width(110));
813+
if (newValue != oldValue)
814+
{
815+
propertyStringStorage[label] = newValue;
816+
if (float.TryParse(newValue, out float v))
817+
{
818+
value = v;
819+
}
820+
}
821+
}
822+
else
823+
{
824+
propertyStringStorage.Add(label, value.ToString());
812825
}
813826

814827
value = GUILayout.HorizontalSlider(value, min, max, GUILayout.Width(330));

0 commit comments

Comments
 (0)