├── addons └── editorscriptmanager │ ├── icon.png │ ├── plugin.cfg │ └── EditorScriptManager.gd ├── .gitignore ├── README.md └── LICENSE /addons/editorscriptmanager/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbMercy/EditorScriptManager/HEAD/addons/editorscriptmanager/icon.png -------------------------------------------------------------------------------- /addons/editorscriptmanager/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name="EditorScriptManager" 4 | description="A simple tool to run EditorScripts from a dropdown menu." 5 | author="bbMercy" 6 | version="1.0" 7 | script="EditorScriptManager.gd" 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | .godot/ 3 | 4 | # Godot-specific ignores 5 | .import/ 6 | export.cfg 7 | export_presets.cfg 8 | 9 | # Imported translations (automatically generated from CSV files) 10 | *.translation 11 | 12 | # Mono-specific ignores 13 | .mono/ 14 | data_*/ 15 | mono_crash.*.json 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | https://github.com/user-attachments/assets/de2ba0c2-13ab-44b7-b784-86f7bcbee9d6 4 | 5 | 6 | --- 7 | 8 | A very simple addon. Adds a small "Run" Button to the Toolbar. 9 | 10 | When selected, the addon searches through your projects' directories, 11 | 12 | and displays any EditorScripts in a PopupMenu. 13 | 14 | From there, selecting any of the options will run the corresponding 15 | 16 | EditorScript's _run() function. 17 | 18 | --- 19 | 20 | Obviates the need to manually navigate and open an EditorScript, 21 | 22 | then call File->Run, one-at-a-time. 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 bbMercy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /addons/editorscriptmanager/EditorScriptManager.gd: -------------------------------------------------------------------------------- 1 | @tool 2 | extends EditorPlugin 3 | 4 | var run_button:MenuButton 5 | 6 | var filesys:EditorFileSystemDirectory 7 | var all_dirs:Array[EditorFileSystemDirectory] 8 | 9 | var editorscript_filepath:Array[String] 10 | var editorscript_name:Array[String] 11 | 12 | 13 | ## adds the button to the editor, connects needed signals to functions 14 | func _ready()->void: 15 | if run_button: 16 | return 17 | run_button=MenuButton.new() 18 | run_button.flat=true 19 | run_button.text="Run" 20 | add_control_to_container(EditorPlugin.CONTAINER_TOOLBAR,run_button) 21 | run_button.connect("about_to_popup",get_editor_scripts) 22 | run_button.get_popup().connect("index_pressed",run_editor_script) 23 | 24 | 25 | 26 | ## recursive get directories function 27 | func get_all_dirs(filesystem:EditorFileSystemDirectory)->Array[EditorFileSystemDirectory]: 28 | var all_directories:Array[EditorFileSystemDirectory] = [] 29 | all_directories.append(filesystem) 30 | for x:int in filesystem.get_subdir_count(): 31 | all_directories.append(filesystem.get_subdir(x)) 32 | for nested_dir:EditorFileSystemDirectory in get_all_dirs(filesystem.get_subdir(x)): 33 | all_directories.append(nested_dir) 34 | return all_directories 35 | 36 | 37 | ## gets all instances of your EditorScripts in your project directory, and adds them to two lookup arrays: 38 | ## one for the EditorScripts name, and the other for its absolute project path. 39 | func get_editor_scripts()->void: 40 | editorscript_filepath.clear() 41 | editorscript_name.clear() 42 | run_button.get_popup().clear() 43 | filesys=EditorInterface.get_resource_filesystem().get_filesystem() 44 | all_dirs=get_all_dirs(filesys) 45 | for index:int in all_dirs.size(): 46 | for file_index in all_dirs[index].get_file_count(): 47 | if all_dirs[index].get_file_script_class_extends(file_index)=="EditorScript"\ 48 | and not editorscript_name.has(all_dirs[index].get_file(file_index)): 49 | editorscript_filepath.append(all_dirs[index].get_file_path(file_index)) 50 | editorscript_name.append(all_dirs[index].get_file(file_index)) 51 | if editorscript_name.size()>0 and run_button!=null: 52 | for x:String in editorscript_name: 53 | run_button.get_popup().add_item(x) 54 | 55 | 56 | ## when you select an option on the PopupMenu, runs the selected script, by index. 57 | func run_editor_script(index:int)->void: 58 | if editorscript_filepath.size()>0: 59 | var script:Resource=load(editorscript_filepath[index]) 60 | var this_script=script.new() 61 | this_script._run() 62 | --------------------------------------------------------------------------------