void Load() { string aFilePath = Application.dataPath + "/Resources Localization/langeditor.ini"; if (System.IO.File.Exists(aFilePath)) { string s = LoadFromTxt(aFilePath, System.Text.Encoding.UTF8); LanguageItems litems = JsonReader.Deserialize <LanguageItems>(s); if (litems == null) { langItems = new List <LangEditor.LanguageItem>(); } else { langItems = new List <LanguageItem>(litems.langItems); langCode = litems.langCode; OSXOpenOffice = litems.OSXOpenOffice; WINOpenOffice = litems.WINOpenOffice; async = litems.async; } } else { langItems.Add(new LanguageItem()); langItems.Last().publicKey = "0AlVMfPD5xIYAdGhKVGNlVkNydWZFc0RHLXlNTUNURWc"; //langItems.Last().documentURL = "https://docs.google.com/spreadsheet/ccc?key=0AlVMfPD5xIYAdGhKVGNlVkNydWZFc0RHLXlNTUNURWc"; langItems.Last().odsFileName = "Localization"; //langItems.Last().odsURL = "https://docs.google.com/spreadsheet/pub?key=0AlVMfPD5xIYAdGhKVGNlVkNydWZFc0RHLXlNTUNURWc&output=ods"; langItems.Last().selected = true; } }
private void InitSpeechBubble() { if (_initialized) { initAgain = false; if (!style.IsNone) { bubbleStyle = _skin.GetStyle(style.Value + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if (bubbleStyle == null) { bubbleStyle = _skin.GetStyle(style.Value); } } else { bubbleStyle = _skin.GetStyle(_style + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if (bubbleStyle == null) { bubbleStyle = _skin.GetStyle(_style); } } #if UNITY_IPHONE if (bubbleStyle != null) { bubbleStyle.fontSize = 0; bubbleStyle.fontStyle = FontStyle.Normal; } #endif if (!offset.IsNone) { bubbleOffset = offset.Value; } else { bubbleOffset = _offset; } bubbleOffsetVector = _offsetVector; if (!id.IsNone) { rawText = Lang.GetText( dictionary.IsNone ? "" : dictionary.Value, id.Value, text.IsNone ? "" : text.Value.Trim() ); lastLanguage = Lang.selectedLanguage; } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); bubbleState = SpeechBubble.BubbleState.effectin; } else { initAgain = true; } }
public bool IsSupportedLanguage(Lang.LanguageCode langCode) { foreach (LangItem item in supportedLanguages) { if (item.included && item.langCode == langCode) { return(true); } } return(false); }
public void ReInitSayText() { if (!id.IsNone) { rawText = Lang.GetText( dictionary.IsNone ? "" : dictionary.Value, id.Value, text.IsNone ? "" : text.Value.Trim() ); lastLanguage = Lang.selectedLanguage; } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); }
public override void OnUpdate(){ if(everyFrame) ReInitSayText(); if(bubbleState != SpeechBubble.BubbleState.finishing){ if(delayTmp >= 0f) { delayTmp -= Time.deltaTime; } else { if(mouseExit) CheckMouseExit(); if((lastLanguage != Lang.selectedLanguage) || (!id.IsNone && lastId != id.Value)){ lastLanguage = Lang.selectedLanguage; if(!id.IsNone) { lastId = id.Value; rawText = Lang.GetText( dictionary.IsNone ? "" : (dictionary.Value + (_appendLanguage ? "_" + Lang.selectedLanguage.ToString() : "")), id.Value, text.IsNone ? "" : text.Value.Trim() ); } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); } if(_initialized && delayTmp < 0f ){ if(!audioDelaySet){ audioDelayTmp = audioDelay.IsNone ? _audioDelay : audioDelay.Value; audioDelaySet = true; } if(!audioStarted) { if(audioDelayTmp > 0f){ audioDelayTmp -= Time.deltaTime; } else { PlayAudio(); audioStarted = true; } } if(bubbleState == SpeechBubble.BubbleState.effectin && alpha <= 1f) { alpha += (1f/(fadeIn.IsNone ? _fadeIn : fadeIn.Value))*Time.deltaTime; if(alpha > 1f) { alpha = 1f; bubbleState = SpeechBubble.BubbleState.bubble; } if(fadeAudioIn) if(goaudio && goaudio.audio) { goaudio.audio.volume = audioSourceVolume + (((volume.IsNone? _volume : volume.Value) - audioSourceVolume) * alpha); } } if(bubbleState == SpeechBubble.BubbleState.effectout && alpha >= 0f) { alpha -= (1f/(fadeOut.IsNone ? _fadeOut : fadeOut.Value))*Time.deltaTime; if(alpha < 0f) { alpha = 0f; bubbleState = SpeechBubble.BubbleState.finishing; Finish(); if(audioFinished) { if(audioFinishedEvent != null) Fsm.Event(audioFinishedEvent); } else { if(finishedEvent != null) Fsm.Event(finishedEvent); } } if(fadeAudioOut) if(goaudio && goaudio.audio) goaudio.audio.volume = (volume.IsNone? _volume : volume.Value) * alpha; return; } } if(!time.IsNone && bubbleState != SpeechBubble.BubbleState.effectout) { if(timeTmp > 0f) { timeTmp -= Time.deltaTime; } else { bubbleState = SpeechBubble.BubbleState.effectout; } } } if(!greaterThanFinish.IsNone && goaudio != null){ if(goaudio.audio != null && goaudio.audio.clip != null){ if(goaudio.audio.isPlaying && goaudio.audio.time > greaterThanFinish.Value - (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) { audioFinished = true; bubbleState = SpeechBubble.BubbleState.effectout; } } } if(waitForAudioFinish && bubbleState != SpeechBubble.BubbleState.effectout) { if(audio.isPlaying && audio.time > audio.clip.length - (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) { audioFinished = true; bubbleState = SpeechBubble.BubbleState.effectout; } } } }
public void ReInitSayText(){ if(!id.IsNone) { rawText = Lang.GetText( dictionary.IsNone ? "" : dictionary.Value, id.Value, text.IsNone ? "" : text.Value.Trim() ); lastLanguage = Lang.selectedLanguage; } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); }
private void InitSpeechBubble(){ if(_initialized){ initAgain = false; if(!style.IsNone) { bubbleStyle = _skin.GetStyle(style.Value + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if(bubbleStyle == null) bubbleStyle = _skin.GetStyle(style.Value); } else { bubbleStyle = _skin.GetStyle(_style + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if(bubbleStyle == null) { bubbleStyle = _skin.GetStyle(_style); } } #if UNITY_IPHONE if(bubbleStyle != null) { bubbleStyle.fontSize = 0; bubbleStyle.fontStyle = FontStyle.Normal; } #endif if(!offset.IsNone) bubbleOffset = offset.Value; else bubbleOffset = _offset; bubbleOffsetVector = _offsetVector; if(!id.IsNone) { rawText = Lang.GetText( dictionary.IsNone ? "" : dictionary.Value, id.Value, text.IsNone ? "" : text.Value.Trim() ); lastLanguage = Lang.selectedLanguage; } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); bubbleState = SpeechBubble.BubbleState.effectin; } else { initAgain = true; } }
public override void Reset() { langCode = Lang.LanguageCode.Unassigned; }
public override void OnUpdate() { if (everyFrame) { ReInitSayText(); } if (bubbleState != SpeechBubble.BubbleState.finishing) { if (delayTmp >= 0f) { delayTmp -= Time.deltaTime; } else { if (mouseExit) { CheckMouseExit(); } if ((lastLanguage != Lang.selectedLanguage) || (!id.IsNone && lastId != id.Value)) { lastLanguage = Lang.selectedLanguage; if (!id.IsNone) { lastId = id.Value; rawText = Lang.GetText( dictionary.IsNone ? "" : (dictionary.Value + (_appendLanguage ? "_" + Lang.selectedLanguage.ToString() : "")), id.Value, text.IsNone ? "" : text.Value.Trim() ); } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); } if (_initialized && delayTmp < 0f) { if (!audioDelaySet) { audioDelayTmp = audioDelay.IsNone ? _audioDelay : audioDelay.Value; audioDelaySet = true; } if (!audioStarted) { if (audioDelayTmp > 0f) { audioDelayTmp -= Time.deltaTime; } else { PlayAudio(); audioStarted = true; } } if (bubbleState == SpeechBubble.BubbleState.effectin && alpha <= 1f) { alpha += (1f / (fadeIn.IsNone ? _fadeIn : fadeIn.Value)) * Time.deltaTime; if (alpha > 1f) { alpha = 1f; bubbleState = SpeechBubble.BubbleState.bubble; } if (fadeAudioIn) { if (goaudio && goaudio.audio) { goaudio.audio.volume = audioSourceVolume + (((volume.IsNone? _volume : volume.Value) - audioSourceVolume) * alpha); } } } if (bubbleState == SpeechBubble.BubbleState.effectout && alpha >= 0f) { alpha -= (1f / (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) * Time.deltaTime; if (alpha < 0f) { alpha = 0f; bubbleState = SpeechBubble.BubbleState.finishing; Finish(); if (audioFinished) { if (audioFinishedEvent != null) { Fsm.Event(audioFinishedEvent); } } else { if (finishedEvent != null) { Fsm.Event(finishedEvent); } } } if (fadeAudioOut) { if (goaudio && goaudio.audio) { goaudio.audio.volume = (volume.IsNone? _volume : volume.Value) * alpha; } } return; } } if (!time.IsNone && bubbleState != SpeechBubble.BubbleState.effectout) { if (timeTmp > 0f) { timeTmp -= Time.deltaTime; } else { bubbleState = SpeechBubble.BubbleState.effectout; } } } if (!greaterThanFinish.IsNone && goaudio != null) { if (goaudio.audio != null && goaudio.audio.clip != null) { if (goaudio.audio.isPlaying && goaudio.audio.time > greaterThanFinish.Value - (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) { audioFinished = true; bubbleState = SpeechBubble.BubbleState.effectout; } } } if (waitForAudioFinish && bubbleState != SpeechBubble.BubbleState.effectout) { if (audio.isPlaying && audio.time > audio.clip.length - (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) { audioFinished = true; bubbleState = SpeechBubble.BubbleState.effectout; } } } }
public void InitDictionary(){ Debug.Log("DICTIONARY INITIALIZED : " + aliasName + " ASSET PATH : " + assetPath + " LANGUAGE : " + Lang.selectedLanguage.ToString()); TextAsset ta = (TextAsset)Resources.Load(assetPath, typeof(TextAsset)); if(ta == null){ Debug.LogError("DICTIONARY NOT FOUND AT RESOURCE PATH: " + assetPath); return; } languages.Clear(); dictionary.Clear(); string id = ""; string line = ""; string[] defs = new string[0]; string[] values = new string[0]; MemoryStream stream = new MemoryStream(ta.bytes); StreamReader sr = new StreamReader(stream); line = sr.ReadLine(); defs = line.ToUpper().Split(";".ToCharArray()[0]); for(int i = 1; i<defs.Length;i++){ languages.Add(GetLanguageEnum(defs[i])); } while(!sr.EndOfStream){ line = sr.ReadLine(); line = line.Replace(@"\;","_semicolon"); values = line.Split(";".ToCharArray()[0]); for(int k = 0; k<languages.Count + 1;k++){ if(k==0){ id = values[k]; } else { if(selectedLanguage == languages[k-1]){ if(dictionary.ContainsKey(id)){ Debug.LogError("DICTIONARY : " + aliasName + " ALREADY CONTAINS KEY : " + id); } else { try{ dictionary.Add(id, values[k].Replace("_semicolon",";").Replace(@"\n","\n")); } catch (Exception e){ Debug.LogError("DICTIONARY : " + aliasName + " KEY : " + id + " " + e.Message); } } } } } } sr.Close(); stream.Close(); Resources.UnloadAsset(ta); langCode = selectedLanguage; }
void Load(){ string aFilePath = Application.dataPath + "/Resources Localization/langeditor.ini"; if(System.IO.File.Exists(aFilePath)){ string s = LoadFromTxt(aFilePath, System.Text.Encoding.UTF8); LanguageItems litems = JsonReader.Deserialize<LanguageItems>(s); if(litems == null) { langItems = new List<LangEditor.LanguageItem>(); } else { langItems = new List<LanguageItem>(litems.langItems); langCode = litems.langCode; OSXOpenOffice = litems.OSXOpenOffice; WINOpenOffice = litems.WINOpenOffice; async = litems.async; } } else { langItems.Add(new LanguageItem()); langItems.Last().publicKey = "0AlVMfPD5xIYAdGhKVGNlVkNydWZFc0RHLXlNTUNURWc"; //langItems.Last().documentURL = "https://docs.google.com/spreadsheet/ccc?key=0AlVMfPD5xIYAdGhKVGNlVkNydWZFc0RHLXlNTUNURWc"; langItems.Last().odsFileName = "Localization"; //langItems.Last().odsURL = "https://docs.google.com/spreadsheet/pub?key=0AlVMfPD5xIYAdGhKVGNlVkNydWZFc0RHLXlNTUNURWc&output=ods"; langItems.Last().selected = true; } }
void OnGUI(){ EditorGUILayout.BeginHorizontal(); if(GUILayout.Button("Save")){ Save(); ShowNotification(new GUIContent("Dictionaries saved")); } if(GUILayout.Button("Load")){ Load(); ShowNotification(new GUIContent("Dictionaries loaded")); } if(GUILayout.Button("Add")){ langItems.Add(new LanguageItem()); } if(GUILayout.Button("Update Camera")){ LangDictionaries ld = Camera.main.gameObject.GetComponent<LangDictionaries>() as LangDictionaries; if(ld == null) ld = Camera.main.gameObject.AddComponent<LangDictionaries>() as LangDictionaries; List<LanguageItem> selection = new List<LanguageItem>(from i in langItems where i.selected == true select i); ld.dictionaries.Clear(); ld.langCode = langCode; for(int i = 0; i<selection.Count(); i++){ string fileName = Application.dataPath + "/Resources Localization/" + selection[i].odsFileName + ".ods"; if(System.IO.File.Exists(fileName)){ OdsReadWrite.OdsReaderWriter reader = new OdsReadWrite.OdsReaderWriter(); System.Data.DataSet dataset = reader.ReadOdsFile(fileName); foreach(System.Data.DataTable table in dataset.Tables){ bool isDictionary = false; foreach(System.Data.DataRow row in table.Rows){ if((row[0] as string).ToUpper() == "ID") isDictionary = true; else isDictionary = false; break; } if(isDictionary){ ld.dictionaries.Add(new LangDictionaries.LangDictionary()); ld.dictionaries.Last().aliasName = table.TableName; ld.dictionaries.Last().assetPath = "Dictionaries/" + table.TableName; } } } else { Debug.LogError("FILE NOT EXISTS : " + fileName); } } ShowNotification(new GUIContent("Camera.main dictionaries updated")); } langCode = (Lang.LanguageCode)EditorGUILayout.EnumPopup(langCode, GUILayout.Width(80)); GUILayout.Label("Async", GUILayout.Width(40)); async = EditorGUILayout.Toggle(async, GUILayout.Width(20)); if(GUILayout.Button("Download from GoogleDocs")){ for(int i = 0; i< langItems.Count; i++){ if(langItems[i].selected){ langItems[i].Download(async, ()=>{Repaint();}); } } } EditorGUILayout.EndHorizontal(); OSXOpenOffice = EditorGUILayout.TextField("OpenOffice(OSX)", OSXOpenOffice); WINOpenOffice = EditorGUILayout.TextField("OpenOffice(WIN)", WINOpenOffice); EditorGUILayout.BeginHorizontal(); GUILayout.Box("Filename",GUILayout.Width(263)); //GUILayout.Box("ODS Url",GUILayout.Width(300)); //GUILayout.Box("Document Url",GUILayout.Width(260)); GUILayout.Box("Public Document Key", GUILayout.Width(363)); GUILayout.Box("",GUILayout.Width(20)); GUILayout.Box("Last Download",GUILayout.Width(140)); GUILayout.Box("ODS->TXT",GUILayout.Width(80)); GUILayout.Box("Delete",GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); backgroundColor = GUI.backgroundColor; contentColor = GUI.contentColor; for(int i = 0; i< langItems.Count(); i++){ langItem = langItems[i]; EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = langItems[i].GetColor(); langItem.odsFileName = GUILayout.TextField(langItem.odsFileName, GUILayout.Width(200)); if(GUILayout.Button("Open",GUILayout.Width(60))){ string filePath = Application.dataPath + "/Resources Localization/" + langItems[i].odsFileName + ".ods"; if(!File.Exists(filePath)){ File.Copy(Application.dataPath + "/Foriero/Localization/Templates/Localization.ods", filePath); AssetDatabase.Refresh(); } if(Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX){ System.Diagnostics.Process.Start(OSXOpenOffice, "\"" + filePath + "\""); } else { System.Diagnostics.Process.Start(WINOpenOffice, "\"" + filePath.Replace("/",@"\") + "\""); } } langItem.publicKey = GUILayout.TextField(langItem.publicKey, GUILayout.Width(196)); //langItem.odsURL = GUILayout.TextField(langItem.odsURL, GUILayout.Width(196)); if(GUILayout.Button("Download",GUILayout.Width(100))){ langItems[i].Download(async, ()=>{Repaint();}); } //langItem.documentURL = GUILayout.TextField(langItem.documentURL, GUILayout.Width(196)); if(GUILayout.Button("Open",GUILayout.Width(60))){ Application.OpenURL(langItem.documentURL); } langItem.selected = EditorGUILayout.Toggle(langItem.selected,GUILayout.Width(20)); GUILayout.Box(langItems[i].lastDownload, GUILayout.Width(140)); if(GUILayout.Button("ODS->TXT", GUILayout.Width(80))){ string fileNameOds = Application.dataPath + "/Resources Localization/" + langItems[i].odsFileName + ".ods"; if(!File.Exists(fileNameOds)){ File.Copy(Application.dataPath + "/Foriero/Localization/Templates/Localization.ods", fileNameOds); AssetDatabase.Refresh(); } ODSToDictionary(fileNameOds); } if(GUILayout.Button("Delete")){ langItems.Remove(langItems[i]); break; } if(langItem.errorMessage != "OK") GUI.contentColor = Color.red; GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; EditorGUILayout.EndHorizontal(); } }
void OnGUI() { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save")) { Save(); ShowNotification(new GUIContent("Dictionaries saved")); } if (GUILayout.Button("Load")) { Load(); ShowNotification(new GUIContent("Dictionaries loaded")); } if (GUILayout.Button("Add")) { langItems.Add(new LanguageItem()); } if (GUILayout.Button("Update Camera")) { LangDictionaries ld = Camera.main.gameObject.GetComponent <LangDictionaries>() as LangDictionaries; if (ld == null) { ld = Camera.main.gameObject.AddComponent <LangDictionaries>() as LangDictionaries; } List <LanguageItem> selection = new List <LanguageItem>(from i in langItems where i.selected == true select i); ld.dictionaries.Clear(); ld.langCode = langCode; for (int i = 0; i < selection.Count(); i++) { string fileName = Application.dataPath + "/Resources Localization/" + selection[i].odsFileName + ".ods"; if (System.IO.File.Exists(fileName)) { OdsReadWrite.OdsReaderWriter reader = new OdsReadWrite.OdsReaderWriter(); System.Data.DataSet dataset = reader.ReadOdsFile(fileName); foreach (System.Data.DataTable table in dataset.Tables) { bool isDictionary = false; foreach (System.Data.DataRow row in table.Rows) { if ((row[0] as string).ToUpper() == "ID") { isDictionary = true; } else { isDictionary = false; } break; } if (isDictionary) { ld.dictionaries.Add(new LangDictionaries.LangDictionary()); ld.dictionaries.Last().aliasName = table.TableName; ld.dictionaries.Last().assetPath = "Dictionaries/" + table.TableName; } } } else { Debug.LogError("FILE NOT EXISTS : " + fileName); } } ShowNotification(new GUIContent("Camera.main dictionaries updated")); } langCode = (Lang.LanguageCode)EditorGUILayout.EnumPopup(langCode, GUILayout.Width(80)); GUILayout.Label("Async", GUILayout.Width(40)); async = EditorGUILayout.Toggle(async, GUILayout.Width(20)); if (GUILayout.Button("Download from GoogleDocs")) { for (int i = 0; i < langItems.Count; i++) { if (langItems[i].selected) { langItems[i].Download(async, () => { Repaint(); }); } } } EditorGUILayout.EndHorizontal(); OSXOpenOffice = EditorGUILayout.TextField("OpenOffice(OSX)", OSXOpenOffice); WINOpenOffice = EditorGUILayout.TextField("OpenOffice(WIN)", WINOpenOffice); EditorGUILayout.BeginHorizontal(); GUILayout.Box("Filename", GUILayout.Width(263)); //GUILayout.Box("ODS Url",GUILayout.Width(300)); //GUILayout.Box("Document Url",GUILayout.Width(260)); GUILayout.Box("Public Document Key", GUILayout.Width(363)); GUILayout.Box("", GUILayout.Width(20)); GUILayout.Box("Last Download", GUILayout.Width(140)); GUILayout.Box("ODS->TXT", GUILayout.Width(80)); GUILayout.Box("Delete", GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); backgroundColor = GUI.backgroundColor; contentColor = GUI.contentColor; for (int i = 0; i < langItems.Count(); i++) { langItem = langItems[i]; EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = langItems[i].GetColor(); langItem.odsFileName = GUILayout.TextField(langItem.odsFileName, GUILayout.Width(200)); if (GUILayout.Button("Open", GUILayout.Width(60))) { string filePath = Application.dataPath + "/Resources Localization/" + langItems[i].odsFileName + ".ods"; if (!File.Exists(filePath)) { File.Copy(Application.dataPath + "/Foriero/Localization/Templates/Localization.ods", filePath); AssetDatabase.Refresh(); } if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { System.Diagnostics.Process.Start(OSXOpenOffice, "\"" + filePath + "\""); } else { System.Diagnostics.Process.Start(WINOpenOffice, "\"" + filePath.Replace("/", @"\") + "\""); } } langItem.publicKey = GUILayout.TextField(langItem.publicKey, GUILayout.Width(196)); //langItem.odsURL = GUILayout.TextField(langItem.odsURL, GUILayout.Width(196)); if (GUILayout.Button("Download", GUILayout.Width(100))) { langItems[i].Download(async, () => { Repaint(); }); } //langItem.documentURL = GUILayout.TextField(langItem.documentURL, GUILayout.Width(196)); if (GUILayout.Button("Open", GUILayout.Width(60))) { Application.OpenURL(langItem.documentURL); } langItem.selected = EditorGUILayout.Toggle(langItem.selected, GUILayout.Width(20)); GUILayout.Box(langItems[i].lastDownload, GUILayout.Width(140)); if (GUILayout.Button("ODS->TXT", GUILayout.Width(80))) { string fileNameOds = Application.dataPath + "/Resources Localization/" + langItems[i].odsFileName + ".ods"; if (!File.Exists(fileNameOds)) { File.Copy(Application.dataPath + "/Foriero/Localization/Templates/Localization.ods", fileNameOds); AssetDatabase.Refresh(); } ODSToDictionary(fileNameOds); } if (GUILayout.Button("Delete")) { langItems.Remove(langItems[i]); break; } if (langItem.errorMessage != "OK") { GUI.contentColor = Color.red; } GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; EditorGUILayout.EndHorizontal(); } }
public void InitDictionary() { Debug.Log("DICTIONARY INITIALIZED : " + aliasName + " ASSET PATH : " + assetPath + " LANGUAGE : " + Lang.selectedLanguage.ToString()); TextAsset ta = (TextAsset)Resources.Load(assetPath, typeof(TextAsset)); if (ta == null) { Debug.LogError("DICTIONARY NOT FOUND AT RESOURCE PATH: " + assetPath); return; } languages.Clear(); dictionary.Clear(); string id = ""; string line = ""; string[] defs = new string[0]; string[] values = new string[0]; MemoryStream stream = new MemoryStream(ta.bytes); StreamReader sr = new StreamReader(stream); line = sr.ReadLine(); defs = line.ToUpper().Split(";".ToCharArray()[0]); for (int i = 1; i < defs.Length; i++) { languages.Add(GetLanguageEnum(defs[i])); } while (!sr.EndOfStream) { line = sr.ReadLine(); line = line.Replace(@"\;", "_semicolon"); values = line.Split(";".ToCharArray()[0]); for (int k = 0; k < languages.Count + 1; k++) { if (k == 0) { id = values[k]; } else { if (selectedLanguage == languages[k - 1]) { if (dictionary.ContainsKey(id)) { Debug.LogError("DICTIONARY : " + aliasName + " ALREADY CONTAINS KEY : " + id); } else { try{ dictionary.Add(id, values[k].Replace("_semicolon", ";").Replace(@"\n", "\n")); } catch (Exception e) { Debug.LogError("DICTIONARY : " + aliasName + " KEY : " + id + " " + e.Message); } } } } } } sr.Close(); stream.Close(); Resources.UnloadAsset(ta); langCode = selectedLanguage; }