check if int and float values are inside range when loading them

This commit is contained in:
in0finite 2019-07-27 19:04:35 +02:00
parent e58b567b5d
commit 759eb3c8b8

View file

@ -111,7 +111,9 @@ namespace SanAndreasUnity.UI {
public override int Load (string str)
{
return int.Parse (str, System.Globalization.CultureInfo.InvariantCulture);
int value = int.Parse (str, System.Globalization.CultureInfo.InvariantCulture);
value = Mathf.Clamp(value, this.minValue, this.maxValue);
return value;
}
}
@ -135,7 +137,9 @@ namespace SanAndreasUnity.UI {
public override float Load (string str)
{
return float.Parse (str, System.Globalization.CultureInfo.InvariantCulture);
float value = float.Parse (str, System.Globalization.CultureInfo.InvariantCulture);
value = Mathf.Clamp(value, this.minValue, this.maxValue);
return value;
}
}