A little bit better number formatting

This commit is contained in:
Simon Lübeß
2024-06-27 20:50:26 +02:00
parent b96f195afb
commit c908f5a0e7
3 changed files with 36 additions and 5 deletions
+21
View File
@@ -276,6 +276,27 @@ internal class EntityEditor
var value = (T)reference!;
if (format == null && value is float || value is double || value is Half)
{
format = "0.#####";
}
if (!format.StartsWith("%"))
{
if (value is float f)
{
format = f.ToString(format);
}
else if (value is double d)
{
format = d.ToString(format);
}
else if (value is Half h)
{
format = h.ToString(format);
}
}
if (range?.Slider == true)
{
if (ImGui.SliderScalar(fieldId, dataType, (IntPtr)(&value), (IntPtr)(&min), (IntPtr)(&max), format))