public void localiseScene(InterfaceLocalisationData _data) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); Dictionary <string, string> sceneValues = _data.localisationValues[scene.name]; //find gameObjects in scene by keys then set Text from localisation file //but this method can't find inactive gameObjects... foreach (string key in sceneValues.Keys) { GameObject obj = GameObject.Find(key); if (obj != null) { Text _t = obj.GetComponent <Text>(); _t.text = sceneValues[key]; } } }
private void LoadInterfaceLocalisationXML(InterfaceLocalisationData _data, string path) { IEnumerable <XElement> scenes; // <scene> tag XDocument xDoc = XDocument.Load(path); scenes = xDoc.Descendants("scenes").Elements(); foreach (XElement scene in scenes) { string scName = scene.Attribute("name").Value.Trim(); Dictionary <string, string> values = new Dictionary <string, string>(); foreach (XElement el in scene.Elements()) { if (!values.ContainsKey(el.Attribute("name").Value)) { values.Add(el.Attribute("name").Value, el.Value); } } if (!_data.localisationValues.ContainsKey(scName)) { _data.localisationValues.Add(scName, values); } } }