From 446a6f22fa7515172addf6f822048bc93b2006d4 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Mon, 28 Mar 2022 14:48:45 +0200 Subject: [PATCH] Fix using `double` value with `float` values to be casted in Editor --- Source/Editor/CustomEditors/Editors/DoubleEditor.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Editors/DoubleEditor.cs b/Source/Editor/CustomEditors/Editors/DoubleEditor.cs index 06dee3d1b..859b70f4e 100644 --- a/Source/Editor/CustomEditors/Editors/DoubleEditor.cs +++ b/Source/Editor/CustomEditors/Editors/DoubleEditor.cs @@ -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() ?? "")); } } }