Created
March 20, 2017 09:25
-
-
Save Fejuto/f5c696e360f3bd90cf779fc14646b1b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
public class cleanlanguagedropdown : MonoBehaviour { | |
public List<GameObject> Scenes; //put your scenes in here from the editor | |
public List<string> LanguageTags; //put "english" "german" etc in this list from the editor. Must correspond to the dropdown | |
List<GameObject> AllLanguageObjects = new List<GameObject>(); //minor: not public; | |
public GameObject StartEnglish; //i'm not sure what these do so i'm leaving it as is, but can likely be improved in the same manner | |
public GameObject StartGerman; | |
public GameObject StartFrench; | |
public GameObject StartSpanish; | |
void Start() { | |
foreach (var scene in Scenes) { | |
scene.SetActive(true); | |
} | |
foreach (var languageTag in LanguageTags) { | |
AllLanguageObjects.AddRange(GameObject.FindGameObjectsWithTag(languageTag)); | |
} | |
foreach (var scene in Scenes) { | |
scene.SetActive(false); | |
} | |
EnableLanguage(LanguageTags[0]); //enable first language in the list by default | |
StartGerman.SetActive(false); | |
StartFrench.SetActive(false); | |
StartSpanish.SetActive(false); | |
} | |
void EnableLanguage(string tag) { | |
foreach (var languageObject in AllLanguageObjects) { | |
languageObject.SetActive(languageObject.tag == tag); | |
} | |
} | |
public void Dropdown_IndexChanged(int index) { | |
EnableLanguage(LanguageTags[index]); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment