Professional Documents
Culture Documents
Why export?
Originally, Godot did not have any means to export projects. The developers would
compile the proper binaries and build the packages for each platform manually.
When more developers (and even non-programmers) started using it, and when our
company started taking more projects at the same time, it became evident that this
was a bottleneck.
On PC
Distributing a game project on PC with Godot is rather easy. Drop the Godot binary
in the same directory as the project.godot file, then compress the project
directory and you are done.
It sounds simple, but there are probably a few reasons why the developer may not
want to do this. The first one is that it may not be desirable to distribute loads
of files. Some developers may not like curious users peeking at how the game was
made, others may find it inelegant, and so on. Another reason is that the developer
might prefer a specially-compiled binary, which is smaller in size, more optimized
and does not include tools like the editor and debugger.
Finally, Godot has a simple but efficient system for creating DLCs as extra package
files.
On mobile
The same scenario on mobile platforms is a little worse. To distribute a project on
those devices, a binary for each of those platforms is built, then added to a
native project together with the game data.
This can be troublesome because it means that the developer must be familiarized
with the SDK of each platform before even being able to export. While learning each
SDK is always encouraged, it can be frustrating to be forced to do it at an
undesired time.
There is also another problem with this approach: different devices prefer some
data in different formats to run. The main example of this is texture compression.
All PC hardware uses S3TC (BC) compression and that has been standardized for more
than a decade, but mobile devices use different formats for texture compression,
such as PVRTC (iOS) or ETC (Android).
Export menu
After many attempts at different export workflows, the current one has proven to
work the best. At the time of this writing, not all platforms are supported yet,
but the supported platforms continue to grow.
../../../_images/export.png
The export menu will open. However, it will be completely empty. This is because we
need to add an export preset.
../../../_images/export_dialog.png
To create an export preset, click the Add� button at the top of the export menu.
This will open a drop-down list of platforms to choose from for an export preset.
../../../_images/export_preset.png
The default options are often enough to export, so tweaking them is usually not
necessary. However, many platforms require additional tools (SDKs) to be installed
to be able to export. Additionally, Godot needs export templates installed to
create packages. The export menu will complain when something is missing and will
not allow the user to export for that platform until they resolve it:
../../../_images/export_error.png
At that time, the user is expected to come back to the documentation and follow
instructions on how to properly set up that platform.
Export templates
Apart from setting up the platform, the export templates must be installed to be
able to export projects. They can be obtained as a TPZ file (which is a renamed ZIP
archive) from the download page of the website.
Once downloaded, they can be installed using the Install Export Templates option in
the editor:
../../../_images/exptemp.png
Export mode
When exporting, Godot makes a list of all the files to export and then creates the
package. There are 3 different modes for exporting:
../../../_images/expselected.png
Exporting from the command line
In production, it is useful to automate builds, and Godot supports this with the
--export and --export-debug command line parameters. Exporting from the command
line still requires an export preset to define the export parameters. A basic
invocation of the command would be:
You can also configure it to export only the PCK or ZIP file, allowing a single
export to be used with multiple Godot executables. This takes place if the target
name ends with .pck or .zip.
It is often useful to combine the --export flag with the --path flag, and to create
a dedicated export preset for automated export:
PCK format:
Exporting for PC
The simplest way to distribute a game for PC is to copy the executables (godot.exe
on Windows, godot on the rest), compress the folder and send it to someone else.
However, this is often not desired.
Godot offers a more elegant approach for PC distribution when using the export
system. When exporting for PC (Linux, Windows, macOS), the exporter takes all the
project files and creates a data.pck file. This file is bundled with a specially
optimized binary that is smaller, faster and does not contain the editor and
debugger.
Warning
If you export for Windows with embedded PCK files, you will not be able to sign the
program, it will break.
If you install Android Studio, you need to run it once to complete the SDK setup.
Install OpenJDK 8
Download and install OpenJDK 8, newer versions do not work.
Create a debug.keystore
Android needs a debug keystore file to install to devices and distribute non-
release APKs. If you have used the SDK before and have built projects, ant or
eclipse probably generated one for you (on Linux and macOS, you can find it in the
~/.android directory).
If you can't find it or need to generate one, the keytool command from the JDK can
be used for this purpose:
../../../_images/editorsettings.png
Scroll down to the section where the Android settings are located:
../../../_images/androidsdk.png
In that screen, the path to 3 files needs to be set:
Main Icon: The "classic" icon. This will be used on all Android versions up to
Android 8 (Oreo), exclusive. Must be at least 192�192 px.
Adaptive Icons: Starting from Android 8 (inclusive), Adaptive Icons were
introduced. Applications will need to include separate background and foreground
icons to have a native look. The user's launcher application will control the
icon's animation and masking. Must be at least 432�432 px.
See also
It's important to adhere to some rules when designing adaptive icons. Google Design
has provided a nice article that helps to understand those rules and some of the
capabilities of adaptive icons.
Caution
The most important adaptive icon design rule is to have your icon critical elements
inside the safe zone: a centered circle with a diameter of 66dp (264 pixels on
xxxhdpi) to avoid being clipped by the launcher.
If you don't provide some of the requested icons, Godot will replace them using a
fallback chain, trying the next in line when the current one fails:
Main Icon: Provided main icon -> Project icon -> Default Godot main icon.
Adaptive Icon Foreground: Provided foreground icon -> Provided main icon -> Project
icon -> Default Godot foreground icon.
Adaptive Icon Background: Provided background icon -> Default Godot background
icon.
It's highly recommended to provide all requested icons, and at least with the
specified resolutions. Only this way your application will look great on all
Android devices and versions.
Exporting for Google Play Store
Uploading an APK to Google's Play Store requires you to sign using a non-debug
keystore file; such file can be generated like this:
../../../_images/editor-export-presets-android.png
Release: Enter the path to the keystore file you just generated.
Release User: Replace with the key alias.
Release Password: Key password. Note that the keystore password and the key
password currently have to be the same.
Your export_presets.cfg file now contains sensitive information. If you use a
version control system, you should remove it from public repositories and add it to
your .gitignore file or equivalent.
Don't forget to uncheck the Export With Debug checkbox while choosing the APK's
name.
../../../_images/export-with-debug-button.png
Optimizing the APK size
By default, the APK will contain native libraries for both ARMv7 and ARMv8
architectures. This increases its size significantly. To create a smaller APK,
uncheck either Armeabi-v 7a or Arm 64 -v 8a in your project's Android export
preset. This will create an APK that only contains a library for a single
architecture. Note that applications targeting ARMv7 can also run on ARMv8 devices,
but the opposite is not true.
Since August 2019, Google Play requires all applications to be available in 64-bit
form. This means you cannot upload an APK that contains just an ARMv7 library. To
solve this, you can upload several APKs to Google Play using its Multiple APK
support. Each APK should target a single architecture; creating an APK for ARMv7
and ARMv8 is usually sufficient to cover most devices in use today.
You can optimize the size further by compiling an Android export template with only
the features you need. See Optimizing a build for size for more information.
However, if you want to install and run the app, you need to sign it with a trusted
signature. Godot supports automatic signing of packages with external tools.
Also, make sure the Publisher Name you set when exporting the package matches the
name used on the certificate.
Submitted as an "App"
available memory is 1GB
share of 2-4 CPU cores
shared access of GPU power (45%)
Submitted as a "Game" (through Xbox Live Creators Program)
available memory is 5GB
4 exclusive CPU cores and 2 shared CPU cores
exclusive access to GPU power (100%)
Exceeding these memory limitations will cause allocation failures and the
application will crash.
Creating a signing certificate
This requires the MakeCert.exe and Pvk2Pfx.exe tools, which come with the Windows
SDK. If you use Visual Studio, you can open one of its Developer Prompts, since it
comes with these tools and they can be located in the path.
Pvk2Pfx /pvk MyKey.pvk /pi pvkPassword /spc MyKey.cer /pfx MyKey.pfx [/po
pfxPassword]
If you don't specify a password with /po argument, the PFX will have the same
password as the private key.
You will also need to trust this certificate in order to be able to install your
app. Open the Command Prompt as Administrator and run the following command:
../../../_images/UWP_sign_tool.png
After setting that up close the editor settings, go to Project > Export, and select
the UWP preset. Under the Signing options click on the folder next to Certificate
and go to the certificate file. Then enter the pfxPassword in the password field.
../../../_images/UWP_export_signing.png
Your project will now be automatically signed on export.
If you want to sign an exported app manually run SignTool.exe and use the following
command.
Note
If you want to update your already installed app, you must update the version
number on the new package or first uninstall the previous package.
This video tutorial goes over how to export an ICO file with GIMP.
It is also possible to convert a PNG image to an hiDPI-friendly ICO file using this
ImageMagick command:
../../../_images/icon_taskbar_icon.png
To change the taskbar icon, go to Project ? Project Settings ? Application ? Config
? Windows Native Icon. Click on the folder icon and select your ICO file.
../../../_images/icon_project_settings.png
This setting only changes the icon for your exported game on Windows. To set the
icon for macOS, use Macos Native Icon. And for any other platform, use the Icon
setting.
There are known issues when changing the application icon in executables that embed
a PCK file. It's recommended to avoid using rcedit for now if you choose to enable
the Embed Pck option for your Windows export preset in the Export dialog.
The file icon is the icon of the executable that you click on to start the project.
../../../_images/icon_file_icon.png
Before selecting it in the export options, you will need to install an extra tool
called rcedit. You can download it here.
After downloading, you need to tell Godot the path to the rcedit executable on your
computer. Go to Editor ? Editor Settings ? Export ? Windows. Click on the folder
icon for the rcedit entry. Navigate to and select the rcedit executable.
Note
Linux and macOS users will also need to install WINE to use rcedit.
../../../_images/icon_rcedit.png
You should now have everything in place to change the file icon. To do that, you
will need to specify the icon when exporting. Go to Project ? Export. Assuming you
have already created a Windows Desktop preset, select your icon in ICO format in
the Application ? Icon field.
../../../_images/icon_export_settings.png
Note
If rcedit fails to change the icon, you can instead compile your own Windows export
templates with the icon changed. To do so, replace platform/windows/godot.ico with
your own ICO file before compiling export templates.
Once this is done, you can specify your export templates as custom export templates
in your project's Windows export preset.
../../../_images/icon_result.png
Note
If your icon isn't showing up properly, on Windows 10, try clearing the icon cache.
To do so, open the Run dialog and enter ie4uinit.exe -ClearIconCache or
ie4uinit.exe -show.
Downloadable Content: the ability to add features and content to one's game.
Patches: the ability to fix a bug that is present in a shipped product.
Mods: grant other people the ability to create content for one's game.
These tools help developers to extend their development beyond the initial release.
Advantages:
incremental updates/patches
offer DLCs
offer mod support
no source code disclosure needed for mods
more modular project structure
users don't have to replace the entire game
The first part of using them involves exporting and delivering the project to
players. Then, when one wants to add functionality or content later on, they just
deliver the updates via PCK files to the users.
scripts
scenes
shaders
models
textures
sound effects
music
any other asset suitable for import into the game
The PCK files can even be an entirely different Godot project, which the original
game loads in at runtime.
../../../_images/export_pck.png
Another method would be to export from the command line. If the output file ends
with a PCK or ZIP file extension, then the export process will build that type of
file for the chosen platform.
Note
If one wishes to support mods for their game, they will need their users to create
similarly exported files. Assuming the original game expects a certain structure
for the PCK's resources and/or a certain interface for its scripts, then either...
func _your_function():
ProjectSettings.load_resource_pack("res://mod.pck")
# Now one can use the assets as if they had them in the project from the start
var imported_scene = load("res://mod_scene.tscn")
Warning
By default, if you import a file with the same file path/name as one you already
have in your project, the imported one will replace it. This is something to watch
out for when creating DLC or mods (solved easily with a tool isolating mods to a
specific mods subfolder). However, it is also a way of creating patches for one's
own game. A PCK file of this kind can fix the content of a previously loaded PCK.
Note
For a C# project, you need to build the DLL and place it in the project directory
first. Then, before loading the resource pack, you need to load its DLL as follows:
Assembly.LoadFile("mod.dll")
Summary
This tutorial should illustrate how easy adding mods, patches or DLC to a game is.
The most important thing is to identify how one plans to distribute future content
for their game and develop a workflow that is customized for that purpose. Godot
should make that process smooth regardless of which route a developer pursues.
Important
Use the browser-integrated developer console, usually opened with F12, to view
debug information like JavaScript, engine, and WebGL errors.
Attention
Many browsers, including Firefox and Chromium-based browsers, will not load
exported projects when opened locally per file:// protocol. To get around this, use
a local server.
Tip
Python offers an easy method to start a local server. Use python -m http.server
8000 --bind 127.0.0.1 with Python 3 to serve the current working directory at
http://localhost:8000. Refer to MDN for additional information.
Attention
There are significant bugs when running HTML5 projects on iOS (regardless of the
browser). We recommend using iOS' native export functionality instead, as it will
also result in better performance.
WebGL 2
Until the OpenGL ES 3 renderer is removed from Godot in favor of Vulkan, HTML5
export uses WebGL 2 when the GLES3 option is selected.
Warning
Using WebGL 2 is not recommended due to its expected removal from Godot without
replacement.
WebGL 2 is not supported in all browsers. Firefox and Chromium (Chrome, Opera) are
the most popular supported browsers, Safari and Edge do not work. On iOS, all
browsers are based on WebKit (i.e. Safari), so they will also not work.
Limitations
For security and privacy reasons, many features that work effortlessly on native
platforms are more complicated on the web platform. Following is a list of
limitations you should be aware of when porting a Godot game to the web.
Using cookies for data persistence
Users must allow cookies (specifically IndexedDB) if persistence of the user://
file system is desired. When playing a game presented in an iframe, third-party
cookies must also be enabled. Incognito/private browsing mode also prevents
persistence.
For the same reason, the full screen project setting doesn't work unless the engine
is started from within a valid input event handler. This requires customization of
the HTML page.
Audio autoplay
Chrome restricts how websites may play audio. It may be necessary for the player to
click or tap or press a key to enable audio.
See also
Google offers additional information about their Web Audio autoplay policies.
Unimplemented functionality
The following functionality is currently unavailable on the HTML5 platform:
Threads
GDNative
C#
Clipboard synchronization between engine and operating system
Networking other than HTTPClient and WebSocketClient
Tip
Check the list of open HTML5 issues on GitHub to see if the functionality you're
interested in has an issue yet. If not, open one to communicate your interest.
The generated .html file can be used as DirectoryIndex in Apache servers and can be
renamed to e.g. index.html at any time, its name is never depended on by default.
The HTML page draws the game at maximum size within the browser window. This way it
can be inserted into an <iframe> with the game's size, as is common on most web
game hosting sites.
The other exported files are served as they are, next to the .html file, names
unchanged. The .wasm file is a binary WebAssembly module implementing the engine.
The .pck file is the Godot main pack containing your game. The .js file contains
start-up code and is used by the .html file to access the engine. The .png file
contains the boot splash image. It is not used in the default HTML page, but is
included for custom HTML pages.
The .pck file is binary, usually delivered with the MIME-type application/octet-
stream. The .wasm file is delivered as application/wasm.
Caution
Delivering the files with server-side compression is recommended especially for the
.pck and .wasm files, which are usually large in size. The WebAssembly module
compresses particularly well, down to around a quarter of its original size with
gzip compression.
Export options
If a runnable web export template is available, a button appears between the Stop
scene and Play edited Scene buttons in the editor to quickly open the game in the
default browser for testing.
If a path to a Custom HTML shell file is given, it will be used instead of the
default HTML page. See Custom HTML page for Web export.
Head Include is appended into the <head> element of the generated HTML page. This
allows to, for example, load webfonts and third-party JavaScript APIs, include CSS,
or run JavaScript code.
func my_func():
JavaScript.eval("alert('Calling JavaScript per GDScript!');")
The value of the last JavaScript statement is converted to a GDScript value and
returned by eval() under certain circumstances:
HTML5 export templates may be built without support for the singleton to improve
security. With such templates, and on platforms other than HTML5, calling
JavaScript.eval will also return null. The availability of the singleton can be
checked with the JavaScript feature tag:
func my_func3():
if OS.has_feature('JavaScript'):
JavaScript.eval("""
console.log('The JavaScript singleton is available')
""")
else:
print("The JavaScript singleton is NOT available")
Tip
The eval method also accepts a second, optional Boolean argument, which specifies
whether to execute the code in the global execution context, defaulting to false to
prevent polluting the global namespace:
func my_func4():
# execute in global execution context,
# thus adding a new JavaScript global variable `SomeGlobal`
JavaScript.eval("var SomeGlobal = {};", true)