static void Init() { // Get existing open window or if none, make a new one: CSVToPseudoPool window = (CSVToPseudoPool)EditorWindow.GetWindow(typeof(CSVToPseudoPool)); window.Show(); }
void ImportCSV() { // Get the File string file = File.ReadAllText(sourcePath); // Split by lines string[] lines = Regex.Split(file, @"\r\n|\n\r|\n|\r"); // Scriptable scriptableObject = CreateInstance(typeof(PseudoPool)) as PseudoPool; scriptableObject._strings = new List <string>(); for (int i = 0; i < lines.Length; i++) { // Get the _header string[] header = Regex.Split(lines[i], ","); for (int y = 0; y < header.Length; y++) { scriptableObject._strings.Add(header[y]); } } if (!Directory.Exists(dataPath)) { //if it doesn't, create it Directory.CreateDirectory(dataPath); } // Create the asset in the project AssetDatabase.CreateAsset(scriptableObject, dataPath + "/" + "NewLocalizationFile" + ".asset"); AssetDatabase.Refresh(); CSVToPseudoPool window = (CSVToPseudoPool)EditorWindow.GetWindow(typeof(CSVToPseudoPool)); window.Close(); }