The GoZen modular system is designed to allow developers and users to extend the editing experience and feel without having to alter the project's core source code. Modules can give you new UI panels, visual/audio effects, transitions, custom scenes (PCK clips), and UI themes.
Modules are loaded from two primary locations:
- Built-in (Local):
res://modules/- Modules shipped with the editor; - User Installed (Global):
user://modules/- Modules installed by the user via.gzmodulefiles.
Every module is defined by a module.tres file at its root, which uses the GoZenModule class. This resource acts as the config file for the module and contains:
- Metadata:
name,description,author,version, andsettings. - Content Arrays:
custom_panels: Array ofGoZenModulePanel(injects UI into the WorkspaceManager);custom_scenes: Array ofGoZenModuleScene(allows.gzsceneclips to run custom Godot scenes on the timeline);custom_themes: Array ofGoZenModuleTheme(adds custom look-and-feel themes);custom_effects: Array ofGoZenModuleEffect(injects new Audio/Visual effects);custom_transitions: Array ofGoZenModuleTransition(injects custom transitions);
During the editor's startup (_enter_tree), the ModuleManager autoload takes care of following tasks:
- Config Loading: First it reads the
user://modules_config.jsonfile to check which user-installed modules are enabled/disabled; - Package Mounting: It iterates through the global user modules. If enabled, it uses
ProjectSettings.load_resource_pack()to mount the.gzmoduleinto the virtualres://file system; - Resource Scanning: It scans
res://modules/for any directories containing amodule.tresfile and stores them in memory; - Registration:
- Panels are made available to
WorkspaceManager; - Effects and Transitions are made available to
EffectsHandler; - Themes are added to
Settings.custom_themes;
- Panels are made available to
Users can install external modules via the Module Manager UI (Preferences > Module manager). When a .gzmodule is selected:
- The file is physically copied to
user://modules/; - It is added to the
modules_config.jsonand marked as enabled; - A restart is should not be required (but depends on the module and the functionality it adds);
To create a module you need to add a folder to the modules folder with the name you want your module to have (make certain that there are no spaces, replace spaces with '_'). Inside of that folder have a GoZenModule resource which is called module.tres. For knowing how the module system works, take a look at the existing modules.
To create .gzmodule (or .gzscene for scene-only packages) files to share with people, use the pack_modules.gd script for this. Inside of the export variables you have to add the name of your module folder, then from the Godot file manager right click the script and press run. This packs your defined modules into the main repo folder inside of a subfolder called modules, people can load these modules through the step described above "User Module Installation".