Fix log spam from TypeEditor if type is missing

This commit is contained in:
Wojtek Figat
2023-08-16 22:27:17 +02:00
parent dd8e05ed49
commit 66678fc219

View File

@@ -464,6 +464,11 @@ namespace FlaxEditor.CustomEditors.Editors
/// </summary>
public class TypeNameEditor : TypeEditorBase
{
/// <summary>
/// Prevents spamming log if Value contains missing type to skip research in subsequential Refresh ticks.
/// </summary>
private string _lastTypeNameError;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
@@ -484,8 +489,13 @@ namespace FlaxEditor.CustomEditors.Editors
{
base.Refresh();
if (!HasDifferentValues && Values[0] is string asTypename)
if (!HasDifferentValues && Values[0] is string asTypename &&
!string.Equals(asTypename, _lastTypeNameError, StringComparison.Ordinal))
{
_element.CustomControl.Value = TypeUtils.GetType(asTypename);
if (_element.CustomControl.Value == null && asTypename.Length != 0)
_lastTypeNameError = asTypename;
}
}
}
}