3 Revize 31719b1cd3 ... ff8abd442e

Autor SHA1 Zpráva Datum
  ZXW ff8abd442e Merge remote-tracking branch 'origin/main' před 1 rokem
  ZXW 07823b3a99 Merge remote-tracking branch 'origin/main' před 1 rokem
  ZXW 84e67eb0d4 多語言 před 1 rokem

+ 25 - 4
SFGgouhuo/Assets/Config/Lan/MultiLanguage/LanguageMatch.cs

@@ -9,7 +9,7 @@ public class LanguageMatch : MonoBehaviour
     public string configName;
 
 
-
+    private TextScroll txtScroll;
     private Text languageText;
     private TextMeshProUGUI languageTextMeshPro;
 
@@ -17,16 +17,18 @@ public class LanguageMatch : MonoBehaviour
 
     private void Awake()
     {
+
         languageText = GetComponent<Text>();
         languageTextMeshPro = GetComponent<TextMeshProUGUI>();
         img = GetComponent<Image>();
+        txtScroll = transform.parent.GetComponent<TextScroll>();
     }
 
 
 
     void OnEnable()
     {
-       
+
         LanguageMatchManager.Instance.AddScrLanguageMatch(this);
 
     }
@@ -38,12 +40,31 @@ public class LanguageMatch : MonoBehaviour
         }
         else
         {
+
+            LanguageType lt = LanguageMatchManager.Instance.GetCurLanType();
+
+
             if (languageText)
                 languageText.text = str;
             if (languageTextMeshPro)
-                languageTextMeshPro.text = str;
-
+            {
 
+                languageTextMeshPro.text = str;
+                languageTextMeshPro.characterSpacing = 0;
+                languageTextMeshPro.wordSpacing = 0;
+                float interval = lt == LanguageType.cn ? 20 : 10;
+                if (lt == LanguageType.cn)
+                {
+                    languageTextMeshPro.characterSpacing = interval;
+                }
+                else
+                {
+                    languageTextMeshPro.wordSpacing = interval;
+                }
+
+            }
+
+            txtScroll?.CheckScroll();
         }
 
 

+ 83 - 0
SFGgouhuo/Assets/Config/Lan/MultiLanguage/TextScroll.cs

@@ -0,0 +1,83 @@
+using TMPro;
+using UnityEngine;
+using UnityEngine.UI;
+
+
+[RequireComponent(typeof(Mask))]
+[RequireComponent(typeof(Image))]
+public class TextScroll : MonoBehaviour
+{
+
+
+    private TextMeshProUGUI txt;
+    private Text txt1;
+
+    private RectTransform rtf;
+
+    private RectTransform rtfTxt;
+
+    private bool isScroll;
+
+
+    private float scrollLen;
+    private float curPosx;
+    private float scrollSpeed = 20;
+    public void Awake()
+    {
+
+        rtf = GetComponent<RectTransform>();
+
+        txt = rtf.GetChild(0).GetComponent<TextMeshProUGUI>();
+
+        txt1 = rtf.GetChild(0).GetComponent<Text>();
+
+    }
+    public void CheckScroll()
+    {
+        var cttWidth = rtf.rect.width;
+        float len = 0;
+
+        if (txt != null)
+        {
+            len = txt.preferredWidth;
+            rtfTxt = txt.rectTransform;
+        }
+        else if (txt1 != null)
+        {
+            len = txt1.preferredWidth;
+            rtfTxt = txt1.rectTransform;
+        }
+
+        isScroll = len != 0 && (cttWidth < len);
+
+        if (isScroll)
+        {
+            rtfTxt.pivot = new Vector2(0, 0.5f);
+            rtfTxt.anchoredPosition = Vector2.zero;
+            scrollLen = -(len - cttWidth);
+            curPosx = 0;
+        }
+
+    }
+
+
+    public void Update()
+    {
+
+        if (!isScroll) return;
+
+        curPosx -= Time.deltaTime * scrollSpeed;
+
+
+        rtfTxt.anchoredPosition = new Vector2(curPosx, 0);
+
+        if (curPosx < scrollLen)
+        {
+            curPosx = 0;
+        }
+
+    }
+
+
+
+}

+ 11 - 0
SFGgouhuo/Assets/Config/Lan/MultiLanguage/TextScroll.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f31008bf53b78004f8223898acc8d90c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 0
SFGgouhuo/Assets/Scripts/Boot.cs

@@ -12,6 +12,8 @@ public class Boot : MonoBehaviour
     public static ResourcePackage package;
     private async void Awake()
     {
+
+
         if (await InitYooAsset() == EOperationStatus.Succeed)
         {
             gameObject.AddComponent<GameManager>();