Fix DefaultValue attribute support in Custom Editors for unsigned integers

This commit is contained in:
Wojtek Figat
2021-11-29 19:58:57 +01:00
parent 0ab9f11e1d
commit 508896b313

View File

@@ -263,6 +263,19 @@ namespace FlaxEditor.CustomEditors
{
_defaultValue = defaultValueAttribute.Value;
_hasDefaultValue = true;
if (_defaultValue != null && _defaultValue.GetType() != Type.Type)
{
// Workaround for DefaultValueAttribute that doesn't support certain value types storage
if (Type.Type == typeof(sbyte))
_defaultValue = Convert.ToSByte(_defaultValue);
else if (Type.Type == typeof(ushort))
_defaultValue = Convert.ToUInt16(_defaultValue);
else if (Type.Type == typeof(uint))
_defaultValue = Convert.ToUInt32(_defaultValue);
else if (Type.Type == typeof(ulong))
_defaultValue = Convert.ToUInt64(_defaultValue);
}
}
}
if (instanceValues._hasReferenceValue)