-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow to define and load script templates per project #31111
Conversation
Figured this can be salvaged by including |
For the overriding behavior, perhaps we can make it behave similarly to how Linux handles such things: Local scripts are preferred and hide global ones if the names are the same, and you can disable a global script locally by creating a symlink to |
Yeah currently it makes little distinction between the origin of those templates. Once solved, overriding could me made possible. So from local to global, script paths could have this priority:
|
Managed to override templates with the same name to prefer project templates over editor ones (also grouped them): It makes sense to me to have project-specific templates to be at top, don't you think? The default one is always at the top. See how Honestly there should be some kind of script template manager but I'm not willing to make one until it proves to be useful. 🙂 |
Fixed override stuff with updated architecture. Perhaps just disabling overridden templates would be enough, provided that extended template can visually tell that those are in fact overridden. That signifies that those template are still there but inaccessible due to extended template used: So I feel like the ground work is done. Again, a lot of this code could be moved to a dedicated (yet non-existing) Namely, |
Noticed that one could have duplicate project-specific script templates across different folders, so those don't show up in template popup, which can and will lead to confusion. So what could be done instead is to have only one project-specific folder for custom script templates, this also allows to define This would also promote consistency as editor templates cannot have more than one folder, too, and makes the code a bit less complex. @groud would agree we'd rather avoid over-customization. 🙂 Also feel free to suggest a better project setting category/name for this. |
Seems good overall, but I wonder if it's worth supporting both user-specific project templates and If someone really wants user-specific project templates, they can add a symlink in their |
This could possibly allow users to override script templates imposed by a project, possible use cases:
But yeah I'd leave |
Previously it was only possible to create custom script templates per editor instance which could lead to certain name collisions, but now one can create such templates per project tailored for specific use cases. The default path to search for custom script templates is defined in project settings via `editor/script_templates_search_path` setting as `res://script_templates` path, yet this can be configured per project. Templates have at most two origins now: 1. Project-specific, defined in `ProjectSettings`, for instance: - res://script_templates/ 2. Editor script templates, for instance: - %APPDATA%/Godot/script_templates/ As script templates can have the same name over different paths, the override mechanism was also added, enabling project-specific templates over the editor ones.
Thanks! |
Closes #19145 and likely closes #31037.
Summary
res://script_templates
or other place within a project.Description
Previously it was only possible to create custom script templates per editor instance which could lead to certain collisions, but now one can create such templates per project tailored for specific use cases.
The default path to search for custom script templates is defined in project settings via
editor/script_templates/paths
setting asres://script_templates
path, but this can be overridden.Also added template override mechanism as described in #31111 (comment), later revised in #31111 (comment).
Issues
GDScript parser treats templates as invalid. The project runs fine but this could lead to some confusion I believe. These templates must be ignored somehow. (can be salvaged by including .gdignore in template folder).
Supporting multiple folders in project resulted in Allow to define and load script templates per project #31111 (comment), so the feature was dropped.
Warning
Backup your editor settings before testing this PR!
Test project
script-templates-project.zip