12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using UnityEngine;
- public class ChangeLanguage : MonoBehaviour {
- private int lang;
- [SerializeField] private GameObject originalSprite;
- [SerializeField] private GameObject overSprite;
- [SerializeField] private GameObject pressSprite;
- [SerializeField] private Sprite[] sprites;
- [SerializeField] private Sprite[] overSprites;
- [SerializeField] private Sprite[] pressSprites;
- private void Start()
- {
-
- }
- private void Update()
- {
- lang = PlayerPrefs.GetInt("language"); // Current language
- // Set origin sprite
- if (originalSprite != null)
- {
- for (int i = 0; i < sprites.Length; i++)
- {
- if (lang == i)
- {
- originalSprite.GetComponent<SpriteRenderer>().sprite = sprites[i];
- }
- }
- }
- if (overSprite != null)
- {
- for (int i = 0; i < overSprites.Length; i++)
- {
- if (lang == i)
- {
- overSprite.GetComponent<SpriteRenderer>().sprite = overSprites[i];
- }
- }
- }
- // set press button sprite
- if (pressSprite != null)
- {
- for (int i = 0; i < pressSprites.Length; i++)
- {
- if (lang == i)
- {
- pressSprite.GetComponent<SpriteRenderer>().sprite = pressSprites[i];
- }
- }
- }
- }
- }
|