-
Notifications
You must be signed in to change notification settings - Fork 0
/
UILanguageString.cs
38 lines (32 loc) · 1.23 KB
/
UILanguageString.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace LanguageModule {
/// <summary>
/// A simple string to put on GameObject. It changes automatically by language.
/// </summary>
public class UILanguageString : MonoBehaviour {
/// <summary>
/// ShortCode of the string <see cref="LanguageData"/>
/// </summary>
public string stringToDisplay;
/// <summary>
/// FileName of the file where the string is.
/// </summary>
public string stringFileName = "global";
void Start() {
if (stringToDisplay == null || stringToDisplay == "") {
Debug.LogWarning("L'objet " + name + " n'a pas de string associé");
return;
}
if (PlayerPrefs.HasKey("Language")) {
gameObject.GetComponent<Text>().text = LanguageData.GetString(stringToDisplay, PlayerPrefs.GetString("Language"),
stringFileName);
} else {
gameObject.GetComponent<Text>().text = LanguageData.GetString(stringToDisplay,
Application.systemLanguage.ToString(), stringFileName);
}
}
}
}