Scriptum/Assets/TranslateText.cs

58 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TranslateText : MonoBehaviour
{
public string textEnglish;
public string textPolish;
public Text displayText;
private string language;
// Start is called before the first frame update
void Start()
{
language = PlayerPrefs.GetString("language");
if (PlayerPrefs.HasKey("language"))
{
language = PlayerPrefs.GetString("language");
if (language == "English")
{
displayText.text = textEnglish;
}
else if (language == "Polish")
{
displayText.text = textPolish;
}
}
else
{
displayText.text = textEnglish;
}
}
// Update is called once per frame
void Update()
{
language = PlayerPrefs.GetString("language");
if (PlayerPrefs.HasKey("language"))
{
language = PlayerPrefs.GetString("language");
if (language == "English")
{
displayText.text = textEnglish;
}
else if (language == "Polish")
{
displayText.text = textPolish;
}
}
else
{
displayText.text = textEnglish;
}
}
}