Exemplo n.º 1
0
    /// <summary>
    /// Add a new text to localize
    /// NOTE: No intended to use in runtime, this function is for editor only
    /// </summary>
    public bool AddText(string key, string defaultText)
    {
        if (Array.Exists(DefaultLanguage.Text.Data, x => x.StringID == key))
        {
            Debug.Log("A key with this name already exist.");
            return(false);
        }
        for (int i = 0; i < Languages.Length; i++)
        {
            if (Languages[i].Text == null)
            {
                continue;
            }
            bl_LanguageTexts.TextData[] data = new bl_LanguageTexts.TextData[Languages[i].Text.Data.Length + 1];
            for (int e = 0; e < data.Length - 1; e++)
            {
                data[e] = Languages[i].Text.Data[e];
            }
            data[data.Length - 1]          = new bl_LanguageTexts.TextData();
            data[data.Length - 1].StringID = key;
            data[data.Length - 1].Text     = defaultText;
            Languages[i].Text.Data         = data;
#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(Languages[i].Text);
#endif
        }
#if UNITY_EDITOR
        UnityEditor.AssetDatabase.SaveAssets();
#endif
        return(true);
    }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 void RemoveLast()
 {
     for (int i = 0; i < Localization.Languages.Length; i++)
     {
         if (Localization.Languages[i].Text == null)
         {
             continue;
         }
         bl_LanguageTexts.TextData[] data = new bl_LanguageTexts.TextData[Localization.Languages[i].Text.Data.Length - 1];
         for (int e = 0; e < data.Length; e++)
         {
             data[e] = Localization.Languages[i].Text.Data[e];
         }
         Localization.Languages[i].Text.Data = data;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 void AddNewText()
 {
     for (int i = 0; i < Localization.Languages.Length; i++)
     {
         if (Localization.Languages[i].Text == null)
         {
             continue;
         }
         bl_LanguageTexts.TextData[] data = new bl_LanguageTexts.TextData[Localization.Languages[i].Text.Data.Length + 1];
         for (int e = 0; e < data.Length - 1; e++)
         {
             data[e] = Localization.Languages[i].Text.Data[e];
         }
         data[data.Length - 1] = new bl_LanguageTexts.TextData();
         Localization.Languages[i].Text.Data = data;
     }
 }