示例#1
0
    void PrintScore()
    {
        string text = GetComponent <Text>().text;

        text = LocalizedTexts.GetText(LocalizedTexts.Text.Total) + ": " + GameData.currentScore + "/" + GameData.maxScore;
        GetComponent <Text>().text = text;
    }
示例#2
0
    private static void PopulateLocalizedTexts(LocalizedTexts localized, ExcelSheet sheet)
    {
        localized.localizations = sheet.Headers.Select((header, languageIdx) =>
        {
            var keys = sheet.Values.Select(value => value[0]).ToArray();

            return(new LanguageGroup()
            {
                Language = header,
                Localizations = new LocalizedText()
                {
                    localization = keys.Select((key, rowIdx) =>
                    {
                        return new Translation()
                        {
                            Key = key,
                            Translated = sheet.GetRow(rowIdx)[languageIdx]
                        };
                    })
                                   .ToArray()
                }
            });
        })
                                  .ToArray();
    }
示例#3
0
    void PrintNewScore(float score, bool flash)
    {
        GetComponent <Text>().text = LocalizedTexts.GetText(LocalizedTexts.Text.Score) + ": " + score.ToString("F1");

        if (flash)
        {
            m_textFlash.FlashText(Color.green);
        }
    }
示例#4
0
    void SetText(LocalizedTexts.Text text, bool flash = true)
    {
        m_textComponent.text = LocalizedTexts.GetText(text);

        if (flash)
        {
            m_textFlash.FlashText(Color.black);
        }

        m_currentText = text;
    }
示例#5
0
    void PrintGoalScore(Goal goal, bool flash)
    {
        GetComponent <Text>().text = LocalizedTexts.GetText(LocalizedTexts.Text.Goal) + ": " + goal.score + "/" + goal.max;

        if (flash)
        {
            FlashText();
        }

        m_currentGoal = goal;
    }
    private void LoadTextsData()
    {
        CreateDirectory();
        string filePath = EditorUtility.OpenFilePanel("Select localization data file", LocalizationManager.languagesDirectory, "json");

        if (!string.IsNullOrEmpty(filePath))
        {
            CreateNewData();
            string jsonString = File.ReadAllText(filePath);
            localizationData = JsonUtility.FromJson <LocalizedTexts>(jsonString);
        }
    }
    void GetText(string filePath, string key, Action <string> action)
    {
        LocalizedTexts localizedTexts = null;

        StartCoroutine(DownloadFile.Download(filePath, (string jsonString) => {
            localizedTexts        = JsonUtility.FromJson <LocalizedTexts>(jsonString);
            LocalizationItem item = localizedTexts.items.Find(o => o.key == key);
            string result         = "";
            if (item != null)
            {
                result = item.value;
            }
            action.Invoke(result);
        }));
    }
示例#8
0
 public void ChangeLanguage()
 {
     LocalizedTexts.SetLanguage(GetNextLanguage());
 }
 private void CreateNewData()
 {
     localizationData = new LocalizedTexts();
 }
示例#10
0
 private void UpdateLanguage()
 {
     GetComponent <Text>().text = LocalizedTexts.GetText(m_text);
 }