The GameMaker compiler allows you to place Batch files (Windows) or Shell scripts (on macOS and Linux) in your project directory, and in the directory for each extension in your project.
A script file may be placed at the root of your project directory, alongside the project's .yyp file.
A script file may also be placed in the directory of an extension, which may look like this: <project_directory>/extensions/<extension_folder>/.
The extension versions of a script file will be executed first, and its root version will be executed last. The order in which extensions are executed can't be controlled, so an extension developer must ensure that one extension's scripts don't rely on another extension's scripts.
Script files with specific names, placed in any of the directories described above, are executed at various points during the compilation process:
NOTE These steps are listed in the order that they are run, except for those under "Platform-Specific Steps".
Windows Batch File Name | macOS/Linux Shell Script Name | Description |
---|---|---|
pre_project_step.bat | pre_project_step.sh | This is executed before the asset compiler has loaded the project files |
post_project_step.bat | post_project_step.sh | This is executed after the asset compiler has loaded the project files |
pre_run_step.bat | pre_run_step.sh | Only runs when testing the game ("Run" or F5 in the IDE), not run when creating a package This is executed before the game deployment is about to start |
pre_build_step.bat | pre_build_step.sh | This is executed before the asset compiler is asked to build the game |
post_textures.bat | post_textures.sh | This is executed after the textures for your game have been generated. You can use this step to optimise your game textures manually. This script receives an environment variable called TexturesDir, which stores the path to the generated textures. |
post_build_step.bat | post_build_step.sh | This is executed after the asset compiler has been started for building the game |
remote_build_step.bat | remote_build_step.sh | This is executed on the remote machine, when you are on a Windows machine and compiling remotely for macOS/iOS/tvOS or Ubuntu. |
pre_package_step.bat | pre_package_step.sh | This is executed before the final packaging step, which is when all files are ready but the final ZIP file or store package is about to be created |
post_package_step.bat | post_package_step.sh | Only runs when creating a package/executable This is executed after the final packaging step has completed and the final ZIP file or store package has been prepared |
post_run_step.bat | post_run_step.sh | Only runs when testing the game ("Run" or F5 in the IDE), not run when creating a package This is executed when the game is prepared and ready to run; after the script's execution the game is started |
Platform-Specific Steps | ||
pre_gradle_step.bat | pre_gradle_step.sh | Android This is executed when the files necessary for the Android tools have been created, but before Gradle is called. You can use this step to access and modify the Android files yourself, before the Android tools compile it into a final executable. |
These script files are supported when building on all target platforms.
You can retrieve the extension version and any of the extension options in the Batch files/Shell scripts:
Replace <ExtensionName> here with the name of the extension you're using.
If you use multiple extensions that run scripts, for example, Steamworks and GDK, then you'll want to disable Steamworks when exporting to GDK, and vice-versa.
For that, see: How to Disable Extensions?