Fix editor values comparison in properties panel to match serializer rules

This commit is contained in:
Wojtek Figat
2023-02-06 13:44:45 +01:00
parent daff3abdc1
commit 9a84811f35

View File

@@ -198,7 +198,7 @@ namespace FlaxEditor.CustomEditors
{
for (int i = 0; i < Count; i++)
{
if (!Equals(this[i], _referenceValue))
if (!ValueEquals(this[i], _referenceValue))
return true;
}
}
@@ -228,20 +228,23 @@ namespace FlaxEditor.CustomEditors
{
for (int i = 0; i < Count; i++)
{
if (!Equals(this[i], _defaultValue))
{
// Special case for String (null string is kind of equal to empty string from the user perspective)
if (this[i] == null && _defaultValue is string defaultValueStr && defaultValueStr.Length == 0)
continue;
if (!ValueEquals(this[i], _defaultValue))
return true;
}
}
}
return false;
}
}
private static bool ValueEquals(object objA, object objB)
{
// Special case for String (null string is kind of equal to empty string from the user perspective)
if (objA == null && objB is string objBStr && objBStr.Length == 0)
return true;
return Newtonsoft.Json.Utilities.MiscellaneousUtils.DefaultValueEquals(objA, objB);
}
/// <summary>
/// Initializes a new instance of the <see cref="ValueContainer"/> class.
/// </summary>