Преглед на файлове

Squashed commit of the following:

commit 38f1d45d4023d4175e771bddc71ef5a5f1a5bc0f
Author: lvjincheng <48816275+lvjincheng1998@users.noreply.github.com>
Date:   Tue Jan 11 11:05:14 2022 +0800

    调整语言组件、英文翻译
lvjincheng преди 4 години
родител
ревизия
cfe401126a

+ 2 - 2
Assets/BowArrow/Resources/Prefabs/Views/DeviceView.prefab

@@ -308,7 +308,7 @@ RectTransform:
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
   m_AnchoredPosition: {x: 0, y: -186}
-  m_SizeDelta: {x: 105, y: 43}
+  m_SizeDelta: {x: 150, y: 43}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &5015974906289248799
 CanvasRenderer:
@@ -3314,7 +3314,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 108.26143, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 1, y: 0.5}
 --- !u!222 &8677266362387219396

+ 15 - 5
Assets/BowArrow/Scenes/Game.unity

@@ -2454,6 +2454,7 @@ MonoBehaviour:
   textID: 112
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &202607251
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -7636,7 +7637,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 29.270073, y: 0}
+  m_AnchoredPosition: {x: 29.683897, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &589339043
@@ -7654,6 +7655,7 @@ MonoBehaviour:
   textID: 200
   layoutRebuildObject: {fileID: 4154775}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &589339044
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -9859,7 +9861,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 29.270073, y: 0}
+  m_AnchoredPosition: {x: 29.683897, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &694545845
@@ -9877,6 +9879,7 @@ MonoBehaviour:
   textID: 202
   layoutRebuildObject: {fileID: 1349314726}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &694545846
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -15606,7 +15609,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 29.270073, y: 0}
+  m_AnchoredPosition: {x: 29.683897, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1218454288
@@ -15624,6 +15627,7 @@ MonoBehaviour:
   textID: 201
   layoutRebuildObject: {fileID: 146791009}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &1218454289
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -17586,7 +17590,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 48.540146, y: 0}
+  m_AnchoredPosition: {x: 49.367794, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1338115114
@@ -17604,6 +17608,9 @@ MonoBehaviour:
   textID: 203
   layoutRebuildObject: {fileID: 308687316}
   textFormatArgs: []
+  languageFontSizes:
+  - language: 1
+    fontSize: 18
 --- !u!114 &1338115115
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -21216,6 +21223,7 @@ MonoBehaviour:
   textID: 111
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &1550855296
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -24244,6 +24252,7 @@ MonoBehaviour:
   textID: 118
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!1 &1729737763
 GameObject:
   m_ObjectHideFlags: 0
@@ -25587,7 +25596,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 78.540146, y: 0}
+  m_AnchoredPosition: {x: 79.3678, y: 0}
   m_SizeDelta: {x: 0, y: 40}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1845023679
@@ -25605,6 +25614,7 @@ MonoBehaviour:
   textID: 204
   layoutRebuildObject: {fileID: 1428784387}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &1845023680
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 19 - 3
Assets/BowArrow/Scenes/Home.unity

@@ -311,7 +311,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 8.315688, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &219397737
@@ -385,6 +385,7 @@ MonoBehaviour:
   textID: 113
   layoutRebuildObject: {fileID: 1590289749}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!1 &473859496
 GameObject:
   m_ObjectHideFlags: 0
@@ -2101,7 +2102,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 94.94707, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1698308730
@@ -2175,6 +2176,7 @@ MonoBehaviour:
   textID: 114
   layoutRebuildObject: {fileID: 1590289749}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!222 &1727497890
 CanvasRenderer:
   m_ObjectHideFlags: 0
@@ -3428,6 +3430,7 @@ MonoBehaviour:
   textID: 23
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &775978679956224155
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -3767,6 +3770,7 @@ MonoBehaviour:
   textID: 20
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!222 &1528406412555832698
 CanvasRenderer:
   m_ObjectHideFlags: 0
@@ -4358,7 +4362,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 55.437923, y: 0}
   m_SizeDelta: {x: 0, y: 40}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!1 &2473343858706513567
@@ -4448,6 +4452,7 @@ MonoBehaviour:
   textID: 21
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!222 &2606655512327568931
 CanvasRenderer:
   m_ObjectHideFlags: 0
@@ -5406,6 +5411,7 @@ MonoBehaviour:
   textID: 100
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!1 &4140370596014797550
 GameObject:
   m_ObjectHideFlags: 0
@@ -5732,6 +5738,7 @@ MonoBehaviour:
   textID: 14
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!224 &4579178453588385146
 RectTransform:
   m_ObjectHideFlags: 0
@@ -6064,6 +6071,7 @@ MonoBehaviour:
   textID: 400
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &5182241564885084954
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -6161,6 +6169,7 @@ MonoBehaviour:
   textID: 19
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &5512893497294297122
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -6370,6 +6379,7 @@ MonoBehaviour:
   textID: 14
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &5787797361731639782
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -6589,6 +6599,9 @@ MonoBehaviour:
   textID: 99
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes:
+  - language: 1
+    fontSize: 30
 --- !u!1 &5919565798464758091
 GameObject:
   m_ObjectHideFlags: 0
@@ -6792,6 +6805,7 @@ MonoBehaviour:
   textID: 101
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!222 &6616742026690263337
 CanvasRenderer:
   m_ObjectHideFlags: 0
@@ -7603,6 +7617,7 @@ MonoBehaviour:
   textID: 22
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []
 --- !u!114 &8381836545075932415
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -8007,3 +8022,4 @@ MonoBehaviour:
   textID: 18
   layoutRebuildObject: {fileID: 0}
   textFormatArgs: []
+  languageFontSizes: []

+ 42 - 12
Assets/BowArrow/Scripts/Components/TextAutoLanguage.cs

@@ -8,10 +8,11 @@ public class TextAutoLanguage : MonoBehaviour
 {
     [SerializeField] int textID;
     [SerializeField] RectTransform layoutRebuildObject;
-    // static LanguageDefault language = new LanguageDefault();
-    static LanguageDefault language = new LanguageDefault();
+    static LanguageEnum currentLanguageEnum = LanguageEnum.Chinese;
+    static LanguageDefault language = null;
     static HashSet<TextAutoLanguage> textAutoLanguages = new HashSet<TextAutoLanguage>();
     public string[] textFormatArgs = {};
+    [SerializeField] LanguageFontSize[] languageFontSizes = {};
 
     public static void Init()
     {
@@ -21,6 +22,7 @@ public class TextAutoLanguage : MonoBehaviour
 
     public static void ChangeLanguage(LanguageEnum languageEnum) 
     {
+        currentLanguageEnum = languageEnum;
         if (languageEnum == LanguageEnum.Chinese) {
             language = new LanguageDefault();
         } else if (languageEnum == LanguageEnum.English) {
@@ -43,6 +45,11 @@ public class TextAutoLanguage : MonoBehaviour
         return LanguageEnum.Chinese;
     }
 
+    void Awake()
+    {
+        if (language == null) ChangeLanguage(currentLanguageEnum);
+    }
+
     void Start()
     {
         textAutoLanguages.Add(this);
@@ -54,6 +61,8 @@ public class TextAutoLanguage : MonoBehaviour
         textAutoLanguages.Remove(this);
     }
 
+    /**记录组件的默认字体大小 */
+    private int defaultFontSize = -1;
     public void SetText(int textID)
     {
         this.textID = textID;
@@ -62,7 +71,23 @@ public class TextAutoLanguage : MonoBehaviour
         {
             text = String.Format(text, textFormatArgs);
         }
-        this.GetComponent<Text>().text = text;
+        Text textComp = GetComponent<Text>();
+        textComp.text = text;
+        //如果有指定当前语言的字体大小,就更新字体大小,否则恢复默认字体大小
+        if (defaultFontSize == -1) { //首次记录组件的默认字体大小
+            defaultFontSize = textComp.fontSize;
+        } else {
+            textComp.fontSize = defaultFontSize;
+        }
+        if (languageFontSizes.Length > 0) {
+            foreach (var languageFontSize in languageFontSizes)
+            {
+                if (languageFontSize.language == currentLanguageEnum) {
+                    textComp.fontSize = languageFontSize.fontSize;
+                }
+            }
+        }
+        //重置指定节点的布局
         if (layoutRebuildObject)
         {
             LayoutRebuilder.ForceRebuildLayoutImmediate(layoutRebuildObject);
@@ -79,6 +104,11 @@ public class TextAutoLanguage : MonoBehaviour
         SetText(textID);
     }
 }
+[Serializable]
+class LanguageFontSize {
+    public LanguageEnum language;
+    public int fontSize;
+}
 public enum LanguageEnum {
     Chinese, English
 }
@@ -267,10 +297,10 @@ class LanguageEnglish : LanguageDefault {
     public new string text10 = "Not Filled In";
     public new string text11 = "Name Cannot Be Empty";
     public new string text12 = "Saved Successfully";
-    public new string text13 = "Me";
+    public new string text13 = "My";
     public new string text14 = "Connect";
-    public new string text15 = "Trying";
-    public new string text16 = "Activated";
+    public new string text15 = "Connecting";
+    public new string text16 = "Connected";
     public new string text17 = "Break";
     public new string text18 = "Bow";
     public new string text19 = "Arrow";
@@ -332,7 +362,7 @@ class LanguageEnglish : LanguageDefault {
     public new string text96 = "New Player Guide";
     public new string text97 = "Back";
     public new string text98 = "Complete";
-    public new string text99 = "Pass";
+    public new string text99 = "Challenge";
     public new string text100 = "Limit";
     public new string text101 = "Rank";
     public new string text102 = "Game";
@@ -355,11 +385,11 @@ class LanguageEnglish : LanguageDefault {
     //设备页面
     public new string text500 = "GyrCalibrate";
     public new string text501 = "MagCalibrate";
-    public new string text502 = "Identity";
+    public new string text502 = "ResetView";
     public new string text503 = "16G Acc";
     public new string text504 = "64G Acc";
     //主页面
-    public new string text400 = "Quit Game";
+    public new string text400 = "Quit";
     //设置页面
     public new string text300 = "Quit Login";
     public new string text301 = "About Us";
@@ -377,11 +407,11 @@ class LanguageEnglish : LanguageDefault {
     public new string text313 = "ArrowWeight";
     public new string text314 = "{0}Gram";
     //设备校准页面
-    public new string text76 = "Identity";
+    public new string text76 = "ResetView";
     public new string text77 = "Back";
     public new string text78 = "Next";
     public new string text79 = "Complete";
-    public new string text80 = "Identity";
+    public new string text80 = "ResetView";
     public new string text81 = "Point the solid bow to the front, and then click \nthe angle of view to return to the front.";
     public new string text82 = "Calibrate";
     public new string text83 = "Stop";
@@ -395,7 +425,7 @@ class LanguageEnglish : LanguageDefault {
     public new string text200 = "Guide";
     public new string text201 = "Scope";
     public new string text202 = "Acc";
-    public new string text203 = "Identity";
+    public new string text203 = "ResetView";
     public new string text204 = "View Target";
     public new string text205 = "Close";
 

+ 4 - 1
Assets/FPSTester.cs

@@ -37,6 +37,9 @@ public class FPSTester : MonoBehaviour
   
     void OnGUI()  
     {  
-        GUI.Label(new Rect(Screen.width/100,0,100,100),"FPS: "+m_FPS);  
+        GUIStyle labelFont = new GUIStyle();
+        labelFont.normal.textColor = new Color(1, 0.6f, 0.6f); 
+        labelFont.fontSize = 20; 
+        GUI.Label(new Rect(Screen.width/100,Screen.height/100,100,100),"FPS: "+m_FPS, labelFont);  
     }  
 }