public void LoadDictionary(LocalizationScriptableObject newDictionary) { this.targetScriptable = newDictionary; tempDictionary = new LocalizationDictionary(targetScriptable.dictionary); wordKeys = tempDictionary.WordKeys; languageKeys = tempDictionary.LangKeys; //Copy tempEntries = new List <LocalizationEntry>(tempDictionary.Entries); loaded = true; }
private void OnGUI() { EditorGUILayout.Space(); EditorGUILayout.Space(); targetScriptable = (LocalizationScriptableObject)EditorGUILayout.ObjectField(targetScriptable, typeof(LocalizationScriptableObject), false); EditorGUILayout.BeginHorizontal(GUILayout.Height(25)); { EditorGUI.BeginDisabledGroup(targetScriptable == null); if (GUILayout.Button(loaded ? "Reload" : "Load", GUILayout.Height(25))) { LoadDictionary(targetScriptable); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!loaded); if (GUILayout.Button("Save", GUILayout.Height(25))) { tempDictionary.Clear(); tempDictionary.LoadEntries(tempEntries); targetScriptable.dictionary = tempDictionary; if (AssetDatabase.Contains(targetScriptable)) { EditorUtility.SetDirty(targetScriptable); AssetDatabase.SaveAssets(); } } if (GUILayout.Button("Languages", GUILayout.Height(25))) { } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Search by", GUILayout.Width(75)); searchMask = (SearchType)EditorGUILayout.EnumPopup(searchMask, GUILayout.Width(100)); searchValue = EditorGUILayout.TextField(searchValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); if (loaded) { DisplayValues(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); { //if (GUILayout.Button("Add Language")) //{ // if (!tempEntries.Exists(e => e.languageKey == newLanguage)) // { // foreach (var w in wordKeys) // { // var temp = new LocalizationEntry(); // temp.wordKey = w; // temp.languageKey = newLanguage; // tempEntries.Add(temp); // } // languageKeys.Add(newLanguage); // } //} if (GUILayout.Button("Add", GUILayout.Height(30))) { ShowAddPopup(); } } EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //{ // if (GUILayout.Button("Remove Language")) // { // tempEntries.RemoveAll(e => e.languageKey == newLanguage); // languageKeys.Remove(newLanguage); // } // if (GUILayout.Button("Remove Word Key")) // { // tempEntries.RemoveAll(e => e.wordKey == newWordKey); // wordKeys.Remove(newWordKey); // } //} //EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); }