浏览代码

minor fix to font change method to better handle nulls

randoman 6 年之前
父节点
当前提交
5f2f19adde
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/XUnity.AutoTranslator.Plugin.Core/TranslationInfo.cs

+ 2 - 2
src/XUnity.AutoTranslator.Plugin.Core/TranslationInfo.cs

@@ -66,9 +66,9 @@ namespace XUnity.AutoTranslator.Plugin.Core
             var ui = graphic as Text;
 
             var previousFont = ui.font;
-            var newFont = FontCache.GetOrCreate( previousFont.fontSize );
+            var newFont = FontCache.GetOrCreate( previousFont?.fontSize ?? ui.fontSize );
 
-            if( newFont != previousFont )
+            if( !ReferenceEquals( newFont, previousFont ) )
             {
                ui.font = newFont;
                _unfont = obj =>