|command||A string with one of the commands listed below.|
|[optional]||Some of the available commands require an optional argument or arguments. These are explained below for each command.|
The gml_pragma function affects how the YYC target compiles your code and should be called with the different commands to further optimise the final compilation of your project. These commands are effectively pre-processed before the game is compiled and so the function can be placed anywhere in your project and it will still be processed before the game is fully compiled. The available commands are as follows:
- "forceinline" - When the function is called with the "forceinline" pragma in a script resource, the YYC will compile the project with the script inline, rather than referenced. This will give a further processing boost, but care must be taken when using it as it will also inflate the final executable file size, especially if the in-lined code is large and/or used in multiple different places, as well as greatly increase the compile time.
- "global", "[gml code]" - The "global" pragma permits you to call some GML code before anything else and will execute the second GML string at a global scope, before the first room of the game executes. For example:
This will call the script "scr_Init" before the first room of the game is run.
- "PNGCrush" - The "PNGCrush" pragma will use the PNGCrush program on each texture created. Note that this can add significantly to the time that it takes to compile the game, so you don't want it on all the time, although it can make significant savings on final file size.
- "Texgroup.Scale", "[TextureGroupName]", "[Scale Divisor]" - The "Texgroup.Scale" will scale the given texture group on compile. You need to give an additional two arguments here: the "[TexGroupName]", which is the name (a string) of the texture group to scale, and the "[Scale Divisor]" (also a string), which is the divisor you wish to use for the scaling, i.e:
gml_pragma("Texgroup.Scale", "level1", "2");
This will half all the textures in the "level1" texture group.
- "UnityBuild", "[enable/disable]" - If you call the function with this pragma and set the enable/disable argument to true then on compile it will collapse all the .cpp files in the project into a single file which it then uses to build everything, for example:
The benefit of doing a unity build is that builds are faster but the down side is that it does a full build each time so even if you change a single part of the code it will build everything again without using any cached files. This has been added specifically for the Xbox One export using the YYC although it can be called for other builds. For more information on unity builds, please see here.
The above example code will force the script where it is used to be in-lined on compile.