diff --git a/Source/Editor/Windows/Assets/FontWindow.cs b/Source/Editor/Windows/Assets/FontWindow.cs index 63201ea9e..a4e843c42 100644 --- a/Source/Editor/Windows/Assets/FontWindow.cs +++ b/Source/Editor/Windows/Assets/FontWindow.cs @@ -135,7 +135,7 @@ namespace FlaxEditor.Windows.Assets /// protected override void UnlinkItem() { - _textPreview.Font = new FontReference(); + _textPreview.Font = null; base.UnlinkItem(); } diff --git a/Source/Engine/Render2D/FontReference.cs b/Source/Engine/Render2D/FontReference.cs index 0d725a5a6..b8616f428 100644 --- a/Source/Engine/Render2D/FontReference.cs +++ b/Source/Engine/Render2D/FontReference.cs @@ -7,7 +7,7 @@ namespace FlaxEngine /// /// Font reference that defines the font asset and font size to use. /// - public struct FontReference + public class FontReference { [NoSerialize] private FontAsset _font; @@ -96,9 +96,9 @@ namespace FlaxEngine /// true if the specified is equal to this instance; otherwise, false. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(ref FontReference other) + public bool Equals(FontReference other) { - return _font == other._font && _size == other._size; + return !(other is null) && _font == other._font && _size == other._size; } /// @@ -109,7 +109,9 @@ namespace FlaxEngine /// True if font references are equal, otherwise false. public static bool operator ==(FontReference lhs, FontReference rhs) { - return lhs.Equals(ref rhs); + if (lhs is null) + return rhs is null; + return lhs.Equals(rhs); } /// @@ -120,7 +122,9 @@ namespace FlaxEngine /// True if font references are not equal, otherwise false. public static bool operator !=(FontReference lhs, FontReference rhs) { - return !lhs.Equals(ref rhs); + if (lhs is null) + return !(rhs is null); + return !lhs.Equals(rhs); } /// @@ -129,7 +133,7 @@ namespace FlaxEngine if (!(other is FontReference)) return false; var fontReference = (FontReference)other; - return Equals(ref fontReference); + return Equals(fontReference); } /// @@ -137,7 +141,7 @@ namespace FlaxEngine { unchecked { - int hashCode = _font.GetHashCode(); + int hashCode = _font ? _font.GetHashCode() : 0; hashCode = (hashCode * 397) ^ _size; return hashCode; }