private void Start() { if (!StringsLoaded) { return; } Text[] textObjectsInScene = Resources.FindObjectsOfTypeAll <Text>(); foreach (Text text in textObjectsInScene) { if (strings.ContainsKey(text.text)) { text.text = strings[text.text]; } } Image[] imageObjectsInScene = Resources.FindObjectsOfTypeAll <Image>(); foreach (Image image in imageObjectsInScene) { if (images.ContainsKey(image.gameObject.name)) { if (!LocalizationSpriteLibrary.SpriteExists(images[image.gameObject.name])) { Debug.LogWarning("Localization Support: An image named: " + images[image.gameObject.name] + " is declared, but not present in the sprite library. Skipping."); continue; } image.sprite = LocalizationSpriteLibrary.GetSprite(images[image.gameObject.name]); } } }
public static Sprite GetImage(string id) { if (images == null) { Debug.LogError("Localization Support: Tried to get image: " + id + " while Strings XML is not loaded!"); return(null); } if (images.ContainsKey(id)) { if (!LocalizationSpriteLibrary.SpriteExists(images[id])) { Debug.LogError("Localization Support: Tried to get image: " + id + " while it doesn't exist in the sprite library!"); return(null); } return(LocalizationSpriteLibrary.GetSprite(images[id])); } Debug.LogError("Localization Support: Tried to get image which does not exist: " + id); return(null); }