private void ShowButtonSection() { if (GUILayout.Button("Validate IDs")) { ValidateIdFailure failure = ValidateIds(); switch (failure) { case ValidateIdFailure.OKAY: { EditorUtility.DisplayDialog("Validate IDs", "Everything allright", "Okay"); break; } case ValidateIdFailure.EMPTY_ID: { EditorUtility.DisplayDialog("Validate IDs", "At least one ID is empty", "Okay"); break; } case ValidateIdFailure.DUPLICATE_ID: { EditorUtility.DisplayDialog("Validate IDs", "at least two ids are same", "Okay"); break; } case ValidateIdFailure.ID_WITH_SPACE: { EditorUtility.DisplayDialog("Validate IDs", "At least one id has a space", "Okay"); break; } } } if (GUILayout.Button("Validate Texts")) { ValidateTexts(); } if (!_areTextsValid) { EditorGUILayout.HelpBox("There are at least one text empty", MessageType.Error, true); } if (GUILayout.Button("Save")) { EnumGenerator.Generate(_source.AllValues); for (var i = 0; i < _source.Entries.Count; ++i) { _source.Entries[i].ID = (TextId)i; } } if (GUILayout.Button("Save to csv")) { SaveToCsv(); } }
private void LoadFromCsv() { var path = EditorUtility.OpenFilePanel("Load dataBase from csv", Application.dataPath, "csv"); if (path != String.Empty) { var dataBase = CreateInstance <TextDataBase>(); AssetDatabase.CreateAsset(dataBase, "Assets/textDataBase.asset"); var readSource = dataBase; AssetDatabase.SaveAssets(); _textFoldout.Clear(); using StreamReader sr = new StreamReader(path); var line = sr.ReadLine(); if (line != null) { var languageIndices = line.Split(';'); foreach (var index in languageIndices) { readSource.SelectedLanguages.Add(Int32.Parse(index)); } } line = sr.ReadLine(); readSource.CurrentLanguageId = Int32.Parse(line); line = sr.ReadLine(); while (line != null) { var all = line.Split(';'); var entry = new TextEntry { ShadowId = all[0] }; for (var i = 0; i < readSource.SelectedLanguages.Count; ++i) { entry.AllTexts.Add(new StringLanguagePair(readSource.SelectedLanguages[i], all[i + 1])); } readSource.Entries.Add(entry); _textFoldout.Add(true); line = sr.ReadLine(); } _source = readSource; var allIds = readSource.Entries.Select(entry => entry.ShadowId).ToList(); AssetDatabase.SaveAssets(); EnumGenerator.Generate(allIds); for (var i = 0; i < _source.Entries.Count; ++i) { _source.Entries[i].ID = (TextId)i; } Repaint(); } }
public static void ShowWindow() { var path = Path.GetFullPath("BaseTextSetter.cs"); Debug.Log("#SettingsWindow#: " + path); path = Path.GetDirectoryName("#SettingsWindow#: " + path); Debug.Log(path); EnumGenerator.Generate(new List <string>() { "Mock" }); GetWindow <SettingsWindow>("Settings"); }