At the moment I have two scenes set up , I will need to set up more obviously but for now im trying to set up my language selection screen , what im trying to do here . Is basically a player will select the language of choice on the first time of running the game , from then on I want it to remember the choice and move into the next scene without having to chose the language again
public int Language ;
void Start() {
Language = PlayerPrefs.GetInt ("myLanguage",-1);
if(Language == -1)
{
Application.LoadLevel (0);
}
if(Language == 2)
{
Application.LoadLevel(1);
}
IEnumerator playSoundThenLoad()
{
audio.Play ();
yield return new WaitForSeconds (audio.clip.length);
PlayerPrefs.Save ();
Application.LoadLevel (1);
}
Void OnGUI ()
{
if (Application.loadedLevel == 0 )
{
GUI.DrawTexture (new Rect(Screen.width/350f,Screen.height/500f,Screen.width/1f,Screen.height/1f),languageScreen);
GUI.DrawTexture (new Rect(Screen.width/1000f,Screen.height/2000f,Screen.width/1f,Screen.height/14f),MainMenuButtonBar);
GUI.skin.button = englishLanguageSelectionButton;
if ( GUI.Button (new Rect (Screen.width /3.2f, Screen.height /2.8f, Screen.width / 2.5f, Screen.height / 4.4f), ""))
{
PlayerPrefs.SetInt("myLanguage",Language);
Language = 2;
StartCoroutine(playSoundThenLoad());
English = true;
Chinese = false;
Spanish = false;
StartCoroutine(playSoundThenLoad());
}
GUI.skin.button = chineseLanguageSelectionButton;
if (GUI.Button (new Rect(Screen.width/3.2f,Screen.height/1.83f,Screen.width / 2.5f, Screen.height / 4.4f),""))
{
StartCoroutine(playSoundThenLoad());
English = false;
Chinese = true;
Spanish = false;
PlayerPrefs.SetInt("myLanguage",Language);
Language = 3;
}
GUI.skin.button = spanishLanguageSelectionButton;
if (GUI.Button (new Rect (Screen.width / 3.2f, Screen.height /1.35f, Screen.width / 2.5f, Screen.height / 4.4f), ""))
{
StartCoroutine(playSoundThenLoad());
English = false;
Chinese = false;
Spanish = true;
PlayerPrefs.SetInt("myLanguage",Language);
Language = 4;
}
}
}