diff --git a/Source/Engine/Render2D/FontReference.cs b/Source/Engine/Render2D/FontReference.cs
index 0d725a5a6..98bd0d092 100644
--- a/Source/Engine/Render2D/FontReference.cs
+++ b/Source/Engine/Render2D/FontReference.cs
@@ -36,8 +36,16 @@ namespace FlaxEngine
/// The font.
public FontReference(Font font)
{
- _font = font?.Asset;
- _size = font?.Size ?? 30;
+ if (font)
+ {
+ _font = font.Asset;
+ _size = font.Size;
+ }
+ else
+ {
+ _font = null;
+ _size = 30;
+ }
_cachedFont = font;
}
@@ -85,7 +93,11 @@ namespace FlaxEngine
/// Th font or null if descriptor is invalid.
public Font GetFont()
{
- return _cachedFont ?? (_cachedFont = _font?.CreateFont(_size));
+ if (_cachedFont)
+ return _cachedFont;
+ if (_font)
+ _cachedFont = _font.CreateFont(_size);
+ return _cachedFont;
}
///