I am making a game for a company that sells touch screen android kiosks, they want to start implementing multiple languages in the games. The selected language is read off a file which their “lobby” software writes, I have everything working except my switch statement always goes to default. I can see in the console what language is selected.
using UnityEngine;
using System.IO;
using System.Text;
using UnityEngine.UI;
public class Language : MonoBehaviour {
public static string language;
string selectedLanguage;
public Text languageText;
string path;
public bool English, French = false;
void Awake()
{
GameObject[] objs = GameObject.FindGameObjectsWithTag("Language");
if (objs.Length > 1)
{
Destroy(this.gameObject);
}
DontDestroyOnLoad(this.gameObject);
path = "/data/data/com.package.name/files/settings.txt";
if (Application.platform == RuntimePlatform.Android && File.Exists(path))
{
using (FileStream fs = File.OpenRead(path))
{
byte[] b = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);
while (fs.Read(b, 0, b.Length) > 0)
{
language = (temp.GetString(b));
}
Debug.Log("Switch to = " + language);
languageText.text = language;
switch (language)
{
case "English":
English = true;
Debug.Log("English");
break;
case "French":
French = true;
Debug.Log("French");
break;
default:
English = true;
Debug.Log("Default");
break;
}
}
}
}
}