Example #1
0
    void Awake()
    {
        dropdown = transform.Find("Dropdown").GetComponent <Dropdown>();
        dropdown.onValueChanged.AddListener(OnDropDownValueChanged);
        LocalizationSystem.Init(textAsset.text, DataFormat.CSV);
        if (LocalizationSystem.TryGetLanguages(out string[] languages))
        {
            foreach (string item in languages)
            {
                dropdown.AddOptions(new List <Dropdown.OptionData>()
                {
                    new Dropdown.OptionData(item)
                });
            }
            int index = 0;
            for (int i = 0; i < languages.Length; i++)
            {
                if (LocalizationSystem.Language == languages[i])
                {
                    index = i;
                    break;
                }
            }
            dropdown.value = index;
        }

        bool b = true;

        btnSetValue.onClick.AddListener(() =>
        {
            if (b)
            {
                text.SetText("<LT>text2</LT>");
            }
            else
            {
                text.SetText("<LT>text1</LT>");
            }
            b = !b;
        });
    }