hellbound/Assets/Scripts/Game/UI/Elements/LanguageItem.cs

32 lines
766 B
C#
Raw Normal View History

2021-11-26 11:16:25 +03:00
using I2.Loc;
using UnityEngine;
using UnityEngine.UI;
public class LanguageItem : MonoBehaviour
{
[SerializeField] private Image flagImage;
[SerializeField] private Text text;
private string term;
private void Start()
{
term = text.text;
SetTextFromTerm(term);
SetFlagTerm(term);
}
private void SetTextFromTerm(string term)
{
text.text = LocalizationManager.GetTranslation(term);
SetFlagTerm(term);
}
private void SetFlagTerm(string term)
{
if (LocalizationManager.TryGetTranslation("FlagSprite", out string translation, true, 0, true, false, null, term, false))
flagImage.sprite = LocalizationManager.GetTranslatedObject<Sprite>(translation);
}
}