|
|
@@ -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";
|
|
|
|