Bladeren bron

feature check

Scrublord1336 6 jaren geleden
bovenliggende
commit
0e630baaef

+ 5 - 2
src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs

@@ -561,7 +561,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
       private void QueueNewUntranslatedForClipboard( TranslationKey key )
       {
-         if( Settings.CopyToClipboard )
+         if( Settings.CopyToClipboard && Features.SupportsClipboard )
          {
             if( !_textsToCopyToClipboard.Contains( key.RelevantText ) )
             {
@@ -1081,7 +1081,10 @@ namespace XUnity.AutoTranslator.Plugin.Core
                _endpoint.OnUpdate();
             }
 
-            CopyToClipboard();
+            if( Features.SupportsClipboard )
+            {
+               CopyToClipboard();
+            }
 
             if( !Settings.IsShutdown )
             {

+ 25 - 0
src/XUnity.AutoTranslator.Plugin.Core/Features.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace XUnity.AutoTranslator.Plugin.Core
+{
+   public static class Features
+   {
+      public static readonly bool SupportsClipboard = false;
+
+      static Features()
+      {
+         try
+         {
+            SupportsClipboard = typeof( TextEditor )?.GetProperty( "text" )?.GetSetMethod() != null;
+         }
+         catch( Exception )
+         {
+            
+         }
+      }
+   }
+}