Scrublord1336 6 жил өмнө
parent
commit
fd5a80a7ab

+ 2 - 0
src/XUnity.AutoTranslator.Plugin.Core/Constants/Types.cs

@@ -20,6 +20,8 @@ namespace XUnity.AutoTranslator.Plugin.Core.Constants
 
       public static readonly Type WWW = FindType( "UnityEngine.WWW" );
 
+      public static readonly Type UguiNovelText = FindType( "Utage.UguiNovelText" );
+
       private static Type FindType( string name )
       {
          return AppDomain.CurrentDomain.GetAssemblies()

+ 11 - 2
src/XUnity.AutoTranslator.Plugin.Core/Extensions/ComponentExtensions.cs

@@ -14,6 +14,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Extensions
       public static string GetText( this object ui )
       {
          string text = null;
+         var type = ui.GetType();
 
          if( ui is Text )
          {
@@ -34,7 +35,16 @@ namespace XUnity.AutoTranslator.Plugin.Core.Extensions
 
       public static void SetText( this object ui, string text )
       {
-         if( ui is Text )
+         var type = ui.GetType();
+
+         if( type == Constants.Types.UguiNovelText )
+         {
+            Logger.Current.Info( "Setting NovelText: " + text );
+            ( (Text)ui ).text = string.Empty;
+            ( (Text)ui ).text = text;
+            type.GetProperty( "LengthOfView" )?.GetSetMethod()?.Invoke( ui, new object[] { text.Length } );
+         }
+         else if( ui is Text )
          {
             ( (Text)ui ).text = text;
          }
@@ -45,7 +55,6 @@ namespace XUnity.AutoTranslator.Plugin.Core.Extensions
          else
          {
             // fallback to reflective approach
-            var type = ui.GetType();
             type.GetProperty( TextPropertyName )?.GetSetMethod()?.Invoke( ui, new[] { text } );
          }
       }