Open JUSTCAMH opened 9 months ago
What if scripts derived from EditorScript had a "Run" context menu button? The filesystem dock could also react to the existing keyboard shortcut for Run if such a script is selected
That certainly sound better than what we have! Though for my larger project, having these editor scripts in a quick access menu would help avoid scrolling through my hundreds of scripts and resources to find what I need. The editor exposes lots of handy tools via quick access menus, though I don’t believe there’s any way for the user to do the same, and it feels like editor scripts should be the thing to do that.
EditorScript
s could be automatically registered as commands for the command palette (Ctrl+Shift+P). I don't think they need a whole new separate popup window
Now that I think about it would make more sense for EditorScript
to be called EditorCommand
as well. There's a bit of a UX conflict, like "should I choose to make an EditorScript or to register a new command in the command palette?". They kinda solve the same problem. Automatically adding commands to command palette would make it possible to quickly run anything without having to make editor addons
What if scripts derived from EditorScript had a "Run" context menu button?
Scratch that idea, I realized that there are a lot of workflows that could make use of the filesystem dock selection. If we do the context menu it will make it impossible to make scripts that operate on selected files.
So we need some other way
I proposed in #9410 (I didn't see that proposal before I made it :() to be able to add a menu with an annotation like:
@menu("MyMenu/MyCommand")
extends EditorScript
func _run() -> void:
print("Hello World")
I think it would be convenient for script you need pretty often. But I like the Command and the context menu entry ideas too
I proposed in #9410 (I didn't see that proposal before I made it :() to be able to add a menu with an annotation like:
Honestly I think this might be the best approach for running editor scripts because:
Add an ability to bind hotkeys to those editor scripts and it's a very solid way to extend the editor without the need to create a plugin with its own UI
@passivestar Personnaly, I think context menu run would be also great in addition to the ability to add it as a menu item. It's 2 differents use cases: one/few shot(s) execution (allowing to execute it without opening it in the editor (good for csharp script for example)) and more permanent functionalities.
yeah a way to register context menu items would be nice too. this is probably better to do through the plugin system (additional methods on the EditorPlugin
class), and allow users to register context menu actions per file extension (for the filesystem dock). selecting multiple files of the same type would let you execute your callable for every selected file then
(to be clear it's not what I offered before and it's probably not what you meant in your last message, but I think it would be very helpful to add file-specific operations this way)
@passivestar For the context menu, I don't think a "Run" item while right clicking on the editor script should be done by implementing an EditorPlugin
. For me, it should be default.
I know it's a slightly different subject, but currently, I'm using my plugin "commands" registered in the "Project/Tools" menu using AddToolSubmenuItem as a subtitute and I think the Tools menu should be a top level menu instead of being a Project menu child.
@passivestar For the context menu, I don't think a "Run" item while right clicking on the editor script should be done by implementing an EditorPlugin. For me, it should be default.
Speaking of the right click "Run" solution, why do you feel like you'll need to be able to run scripts through the context menu at all? sounds a little redundant when the top menu is always accessible and just all around better solution to the problem. especially if editor scripts are made hotkey-able
Your proposition about the run context menu item was for the filesystem dock. And I think it's pretty relevant, so you don't need to open the script in the script editor...
Describe the project you are working on
Any game
Describe the problem or limitation you are having in your project
Currently, EditorScripts are run from the script editor, by selecting File -> Run with the script selected. This is however incredibly cumbersome to use, as often editor scripts affect the scene, however with the script editor open, the scene is not visible. Furthermore, people using external IDEs would need to open the script editor just to run this code. EditorScripts should be easy access, in a spot that you can run at any time.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add a Run button to the Scene tab in the top left toolbar. Selecting this lets you run an editor script quickly and easily from anywhere in the editor.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I can think of two different ways for this to work. The first would be similar to the "Run Specific Scene" button, where when you select Scene -> Run, it opens a popup with all the editor scripts, then you select the one you want and it runs.
The second option could be with a submenu, where when hovering over run, an additional layer of options appears, with one button for each editor script in the project. When no EditorScripts are present, a simple unselectable message could be shown instead.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No
Is there a reason why this should be core and not an add-on in the asset library?
EditorScript is a core engine feature and is the go-to way to manually execute code in editor, but is currently cumbersome to use