static void Init() { var window = (SceneSearcherWindow)GetWindow(typeof(SceneSearcherWindow)); window.PrepareData(); window.Show(); var generator = new SceneSearcherGenerator(); }
private void DrawFunctionButtons() { GuiLine(); EditorGUILayout.BeginHorizontal(); //Validate data, then write it to file if (GUILayout.Button("Save Changes")) { SaveDataAndPrefs(); } //Reset all plugin data if (GUILayout.Button("Remove All Scenes")) { if (EditorUtility.DisplayDialog("Remove all scenes?", "Are you sure you want to remove all scenes from the menu?", "YES", "NO")) { _scenesData.Scenes.Clear(); SaveDataAndPrefs(); //Remove generated source file var files = AssetDatabase.FindAssets("SceneSearcherWindow", null); if (files.Length != 0) { var thisScriptPath = AssetDatabase.GUIDToAssetPath(files[0]); var pathToFile = Path.GetDirectoryName(thisScriptPath); var fileName = "SceneSearcherGeneratedClass.cs"; File.Delete(pathToFile + "/" + fileName); AssetDatabase.Refresh(); } } } if (GUILayout.Button("Generate Menu")) { var generator = new SceneSearcherGenerator(); if (_scenesData != null && !(_scenesData.Scenes.Count == 0 | _preferences == null)) { var sourceText = generator.GenerateSourceCode(_scenesData, _preferences); var files = AssetDatabase.FindAssets("SceneSearcherWindow", null); if (files.Length != 0) { var thisScriptPath = AssetDatabase.GUIDToAssetPath(files[0]); var pathToSave = Path.GetDirectoryName(thisScriptPath); var fileName = "SceneSearcherGeneratedClass.cs"; WriteToFile(pathToSave + "/" + fileName, sourceText); AssetDatabase.Refresh(); } } } EditorGUILayout.EndHorizontal(); GuiLine(); }