Fix using double value with float values to be casted in Editor

This commit is contained in:
Wojciech Figat
2022-03-28 14:48:45 +02:00
parent 2b83975ea2
commit 446a6f22fa

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System;
using System.Linq;
using FlaxEditor.CustomEditors.Elements;
using FlaxEngine;
@@ -66,7 +67,13 @@ namespace FlaxEditor.CustomEditors.Editors
}
else
{
_element.Value = (double)Values[0];
var value = Values[0];
if (value is double asDouble)
_element.Value = (float)asDouble;
else if (value is float asFloat)
_element.Value = asFloat;
else
throw new Exception(string.Format("Invalid value type {0}.", value?.GetType().ToString() ?? "<null>"));
}
}
}