Hey everyone! I’m with some tricky question here. I was thought about what’s the best way to put an option to language selection for subtitles and texts. Obviously, this is not hard at all, but I was thinking about the best way to change between every language supported.
For each text, I thought in an array of string with n elements, where n is the number of languages supported, but I don’t know how expensive is this for the memory to manage(seems pretty expensive), so I wish someone could guide through this, giving me some hints and a way which can give good results without killing the performance in mobile devices, for example.
I also bring some code. The idea I passed above:
public class languageManager : UnityEngine.MonoBehaviour {
public enum Language {
English,
Portuguese,
Spanish
}
private static Language _curLanguage;
public string[] MENU_Play;
public string[] MENU_Options;
public string[] MENU_Quit;
public string[] MENU_Credits;
[...LOTS OF MORE ARRAYS ABOVE...]
public string getText(string[] texts, Language language) {
return texts[(int)language];
}
public string getTextInCurrentLanguage(string[] texts) {
return texts[(int)_curLanguage];
}
public static Language currentLanguage {
get { return _curLanguage; }
set { _curLanguage = value; }
}
}
Thanks for any help!