Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ jamesramsay
javafx
JIT
jitter
JNI
jobfolder
jpg
js
Expand Down Expand Up @@ -304,6 +305,7 @@ MonoBehaviour
MonoBehaviours
Monteiro
movieclip
MSAA
mutex
Nakama
namespace
Expand Down
35 changes: 35 additions & 0 deletions docs/en/manuals/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,41 @@ For this feature to work, you will need *ADB* installed and *USB debugging* enab

An *.aab* file can be uploaded to Google Play via the [Google Play developer console](https://play.google.com/apps/publish/). It is also possible to generate an *`.apk`* file from an *.aab* file to install it locally using the [Android bundletool](https://developer.android.com/studio/command-line/bundletool).

## Shrinking Java code with R8

R8 reduces the size of Java code through shrinking, optimization and obfuscation.

### Enabling R8

Select `/builtins/manifests/android/dmengine.keep` in **Android ▸ R8 Keep Rules** in *game.project*. This uses Defold's default rules directly:

```ini
[android]
r8_keep_rules = /builtins/manifests/android/dmengine.keep
```

Make sure every extension with Java code provides a `.keep` file for the classes it needs at runtime. Extension rules are combined with the selected project rules when building. Test a release build on a device after enabling R8.

Leaving **R8 Keep Rules** empty uses D8 without shrinking. Enabling R8 uses the native extension build service, even for a project without native extensions.

### Adding rules to an extension

Keep rules for an extension belong in its `manifests/android` directory, next to `build.gradle`. See [R8 keep rules for Android extensions](/manuals/extensions/#r8-keep-rules-for-android) for how to add a file and preserve the extension's Java classes.

### Keeping the obfuscation mapping

Enable **Generate debug symbols** in the Android bundle dialog, or pass `--with-symbols` to Bob, to retain R8's `mapping.txt` when the build produces one. For example, from the project directory:

```sh
java -jar bob.jar --platform arm64-android --variant release \
--archive --with-symbols --bundle-output build/android \
resolve build bundle
```

The mapping is saved as `<binary-name>.apk.symbols/mapping.txt` beside the generated APK or AAB. For example, with the project title `My Game`, the command above produces `build/android/MyGame/MyGame.apk.symbols/mapping.txt`.

Keep the mapping file with the exact release it came from. It maps obfuscated Java names back to the original names for interpreting stack traces; a mapping from a different build may give incorrect results.

## Permissions

The Defold engine requires a number of different permissions for all engine features to work. The permissions are defined in the `AndroidManifest.xml`, specified in the *game.project* [project settings file](/manuals/project-settings/#android). You can read more about Android permissions in [the official docs](https://developer.android.com/guide/topics/permissions/overview). The following permissions are requested in the default manifest:
Expand Down
20 changes: 20 additions & 0 deletions docs/en/manuals/app-manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ Include support for Ogg Opus sound resources. The Opus decoder is excluded by de
Exclude all input handling from the engine.


## Exclude GUI

Remove GUI resources, components and Lua support from the engine. Enable this only if the project does not use GUI scenes or GUI scripts. Label components remain available. This option is disabled by default.


## Exclude Particle FX

Remove particle effect resources, components and the `particlefx` Lua module. This also removes support for particle nodes in GUI scenes; GUI scenes without particle nodes remain supported. Remove references to particle effects and calls to their APIs before enabling this option. It is disabled by default.


## Exclude Tilemaps

Remove tilemap resources, components and the `tilemap` Lua module. Enable this only if the project does not use tilemap components or their APIs. Tile sources used by other components remain available. This option is disabled by default.


## Exclude Live Update

Exclude the [Live Update functionality](/manuals/live-update) from the engine.
Expand Down Expand Up @@ -120,6 +135,11 @@ On Linux ARM64, the **OpenGL** choice uses the OpenGL ES backend. The Android co
If enabled (`true`), this includes the full text layout system for shaping text, including right-to-left languages. Enable this option together with `font.runtime_generation` in *game.project* to use runtime generation for SDF fonts from TrueType (`.ttf`) or OpenType (`.otf`) resources. Runtime generation from `.otf` resources is supported since Defold 1.13.2. Read more in the [Font Manual](/manuals/font/#enabling-runtime-fonts).


## Use Rich Text

Include rich text parsing and style effects for labels and GUI text. This option is enabled by default. Disable it to reduce engine size when the project only needs plain text. Labels and GUI text remain supported, but markup renders as plain text instead of applying formatting or effects.


## Minimum browser versions

The YAML fields **`minSafariVersion`**, **`minFirefoxVersion`**, and **`minChromeVersion`** specify the minimum browser versions targeted by Emscripten. The current defaults and minimum supported versions differ between the non-threaded and threaded targets:
Expand Down
3 changes: 3 additions & 0 deletions docs/en/manuals/editor-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Zoom on Scroll
Auto-insert closing parens
: Automatically inserts matching closing characters while editing code. This option is enabled by default.

Format on save
: Runs the language server formatter on modified open code files when saving. Disabled by default. The language server must support formatting; see [formatting code](/manuals/writing-code/#formatting-code) for formatting a document or selection manually.


### Open script files in Visual Studio Code

Expand Down
28 changes: 27 additions & 1 deletion docs/en/manuals/editor-scripts-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ brief: This manual explains how to create UI elements in the editor using Lua

# Editor scripts and UI

This manual explains how to create interactive UI elements in the editor using editor scripts written in Lua. To get started with editor scripts, see [Editor Scripts manual](/manuals/editor-scripts). You can find the full editor API reference [here](/ref/stable/editor-lua/). Currently, it's only possible to create interactive dialogs, though we want to expand the UI scripting support to the rest of the editor in the future.
This manual explains how to create interactive dialogs and open resources in the editor using editor scripts written in Lua. To get started with editor scripts, see [Editor Scripts manual](/manuals/editor-scripts). You can find the full editor API reference [here](/ref/stable/editor-lua/).

## Hello world

Expand Down Expand Up @@ -53,6 +53,32 @@ Finally, after pressing <kbd>Enter</kbd> (or clicking on the `Perform` button),
Perform action: true
```

## Opening resources

Call `editor.ui.open_resource()` from a command's `run` function to open a project resource. The path starts with `/`. Omitting the view selects the resource's primary view:

```lua
editor.ui.open_resource("/main/main.script")
```

The `code` and `text` views accept a cursor position or a selection as a third argument. Line and column numbers start at `1`; a missing column defaults to `1`. Specify the view when passing these arguments:

```lua
editor.ui.open_resource("/main/main.script", "code", { line = 10 })
editor.ui.open_resource("/main/main.script", "code", { line = 10, column = 5 })
```

To select a range, provide `from` and `to` cursor positions instead:

```lua
editor.ui.open_resource("/main/main.script", "code", {
from = { line = 10, column = 1 },
to = { line = 12, column = 1 }
})
```

The configured resource view may open in the editor or an external application. The built-in Code and Text views support the cursor and selection arguments. See [`editor.ui.open_resource()`](/ref/beta/editor/#editor.ui.open_resource:resource_path-view-args) for supported view names.

## Basic concepts

### Components
Expand Down
6 changes: 4 additions & 2 deletions docs/en/manuals/editor-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,11 @@ Please note that lifecycle hooks currently are an editor-only feature, and they

## Language servers

The editor supports a subset of the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/): diagnostics (lints), completions, hover information, document symbols in the Structure pane, go to definition, find references, and symbol rename. Hover over a symbol to see information from the language server. With the cursor on a symbol, use <kbd>F2</kbd> to rename it, <kbd>F12</kbd> to go to its definition, or <kbd>Shift+F12</kbd> to find references. These actions are also available from the <kbd>Edit</kbd> menu.
The editor supports a subset of the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/): diagnostics (lints), completions, hover information, document symbols in the Structure pane, go to definition, find references, symbol rename, and document/range formatting. Hover over a symbol to see information from the language server. With the cursor on a symbol, use <kbd>F2</kbd> to rename it, <kbd>F12</kbd> to go to its definition, or <kbd>Shift+F12</kbd> to find references. These actions are also available from the <kbd>Edit</kbd> menu. See [formatting code](/manuals/writing-code/#formatting-code) for the formatting command and format-on-save preference.

To define the language server, you need to edit your editor script's `get_language_servers` function like so:
The bundled Lua language server includes Defold type annotations for the runtime and editor scripting APIs. In `.editor_script` files, completion and diagnostics recognize `editor.*` functions and their argument and return types. See [code completion](/manuals/writing-code/#code-completion).

To register an additional language server, define your editor script's `get_language_servers` function like so:

```lua
function M.get_language_servers()
Expand Down
46 changes: 45 additions & 1 deletion docs/en/manuals/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,57 @@ The optional *manifests* folder of an extension contains additional files used i

* `android` - This folder accepts a manifest stub file to be merged into the main application ([as described here](/manuals/extensions-manifest-merge-tool)).
* The folder can also contain a `build.gradle` file with dependencies to be [resolved by Gradle](/manuals/extensions-gradle).
* The folder can also contain R8 keep-rule files (`.keep`) for Java code that needs to be preserved when shrinking is enabled. See the [R8 Keep Rules project setting](/manuals/project-settings/#r8-keep-rules) for setup and migration from the former ProGuard configuration.
* Extensions with Java code should include an [R8 keep-rule file](#r8-keep-rules-for-android) (`.keep`) for the classes they need at runtime.
* `ios` - This folder accepts a manifest stub file to be merged into the main application ([as described here](/manuals/extensions-manifest-merge-tool)).
* The folder can also contain a `Podfile` file with dependencies to be [resolved by Cocoapods](/manuals/extensions-cocoapods).
* `osx` - This folder accepts a manifest stub file to be merged into the main application ([as described here](/manuals/extensions-manifest-merge-tool)).
* `web` - This folder accepts a manifest stub file to be merged into the main application ([as described here](/manuals/extensions-manifest-merge-tool)).


### R8 keep rules for Android

Add a `.keep` file to the extension's `manifests/android` directory, next to `build.gradle`. For example, `/myextension/manifests/android/myextension.keep` can preserve the extension's Java classes with:

```proguard
-keep,allowoptimization class com.example.myextension.** { *; }
```

Replace `com.example.myextension` with the package containing your extension's Java classes. This rule preserves the classes and their members while allowing R8 to optimize their code. Add rules for other classes accessed through the Java Native Interface (JNI) or reflection, since R8 may not discover those uses automatically.

If the extension relies on annotations at runtime, also include:

```proguard
-keepattributes *Annotation*
```

These rules are combined with the project's selected keep file when [R8 is enabled](/manuals/android/#enabling-r8).


## Custom resources

An extension can include data in the game archive by declaring custom resources in an `ext.properties` file next to its `ext.manifest`:

```ini
[project]
custom_resources.default = /myextension/data
```

For example, place a JSON file at `/myextension/data/settings.json`. The path is relative to the project root, including the extension folder. When sharing the extension as a library, include `myextension` in the library's [Include Dirs](/manuals/libraries/#setting-up-library-sharing) so consuming projects receive the extension and its data.

These paths are combined with `project.custom_resources` from *game.project* and contributions from other extensions. Setting custom resources in the project does not replace the extension contributions. Both editor builds and Bob archives include the files, which can be loaded at runtime:

```lua
local data, err = sys.load_resource("/myextension/data/settings.json")
if data then
local settings = json.decode(data)
pprint(settings)
else
print(err)
end
```

See [file access](/manuals/file-access/#custom-resources) for how custom resources differ from bundle resources.

## Sharing an extension

Extensions are treated just like any other assets in your project and they can be shared in the same way. If a native extension folder is added as a Library folder it can be shared and used by others as a project dependency. Refer to the [Library project manual](/manuals/libraries/) for more information.
Expand Down
2 changes: 2 additions & 0 deletions docs/en/manuals/file-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ You can include files with your application using bundle resources and custom re
#### Custom Resources
:[Custom Resources](../shared/custom-resources.md)

Extensions can also contribute these files through `ext.properties`. Their paths are combined with the project's custom resources in both editor builds and Bob archives. See [extension custom resources](/manuals/extensions/#custom-resources).

```lua
-- Load level data into a string
local data, error = sys.load_resource("/assets/level_data.json")
Expand Down
2 changes: 2 additions & 0 deletions docs/en/manuals/font.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ We currently use the libraries [HarfBuzz](https://github.com/harfbuzz/harfbuzz),

See [Enabling Runtime Fonts](/manuals/font#enabling-runtime-fonts)

The editor uses the engine's font renderer for font and scene text previews. Text shaping and right-to-left layout require [runtime fonts](#enabling-runtime-fonts) and the **Use full text layout system** option in the App Manifest. For offline fonts, the preview respects the font's **Characters** and **All Chars** settings.

## Font collection

The `.fontc` file format is also known as a font collection. In offline mode, only one font is associated with it.
Expand Down
3 changes: 2 additions & 1 deletion docs/en/manuals/gui-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ brief: This manual describes how to add text to GUI scenes.

Defold supports a specific type of GUI node that allows text to be rendered in a GUI scene. Any font resource added to a project can be used for text node rendering.

The editor preview supports text shaping and right-to-left layout using the engine's font renderer. See [text layout support](/manuals/font/#text-layout-support-eg-right-to-left) for the required font and App Manifest settings.

## Adding text nodes

The fonts that you wish to use in GUI text nodes must be added to the GUI component. Either right-click the *Fonts* folder, use the <kbd>GUI</kbd> top menu or press the corresponding keyboard shortcut.
Expand Down Expand Up @@ -55,4 +57,3 @@ function on_message(self, message_id, message, sender)
end
end
```

22 changes: 22 additions & 0 deletions docs/en/manuals/html5.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ Defold HTML5 bundles require a modern browser with WebAssembly support. Internet

When you click on the <kbd>Create bundle</kbd> button you will be prompted to select a folder in which to create your application. After the export process completes, you will find all of the files needed to run the application.

## WebGL context version

Select the requested graphics context through [`graphics.webgl_version_hint`](/manuals/project-settings/#webgl-version-hint). Its default is WebGL 2; request WebGL 1 to test or target that context on browsers that support both versions.

## Download verification

The HTML5 loader checks the sizes of downloaded engine and archive files by default. Failed checks cause downloads to be retried before the loader reports an error:

* Network errors, failed HTTP statuses and size mismatches in the engine's JavaScript or WebAssembly download use the retry limit in `html5.retry_count`.
* Archive-file verification has its own retry limit for size or SHA-1 mismatches. Each verification retry downloads the file's pieces again, with the normal network retries available for each download.

The `html5.retry_time` setting controls the delay between retries in both cases.

If your server, proxy or CDN intentionally rewrites served files and changes their sizes, disable size verification in *game.project*:

```ini
[html5]
verify_downloaded_file_size = 0
```

Disabling **Verify Downloaded File Size** leaves any SHA-1 verification included in the bundle enabled. See the [HTML5 project settings](/manuals/project-settings/#verify-downloaded-file-size).

## Known issues and limitations

* Hot Reload - Hot Reload doesn't work in HTML5 builds. Defold applications must run their own miniature web server in order to receive updates from the editor, which isn't possible in a HTML5 build.
Expand Down
2 changes: 2 additions & 0 deletions docs/en/manuals/optimization-size.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Defold will create a dependency tree when building and bundling your application
A quick way to reduce the engine size is to remove functionality in the engine that you do not use. This is done [application manifest file](https://defold.com/manuals/app-manifest/) where it is possible to remove engine components that you do not need. Examples:

* Physics - If your game does not make use of Box2D or Bullet3D physics then it is strongly advised to remove the physics engines
* GUI, particle effects and tilemaps - These components can be excluded separately with the [App Manifest component switches](/manuals/app-manifest/#exclude-gui). Remove component references and API calls for any feature you exclude. Excluding particle effects also removes support for particle nodes in GUI scenes.
* Rich text - Disable [Use Rich Text](/manuals/app-manifest/#use-rich-text) if labels and GUI text only need plain text. This removes rich text parsing and style effects while retaining ordinary text rendering.
* LiveUpdate - If your game does not use LiveUpdate it can be removed
* Image loaded - If your game does not manually load and decode images using `image.load()`
* BasisU - If your game has few textures, compare the build size without BasisU (removed via app manifest) and without texture compression versus a build with BasisU and compressed textures. For games with limited textures, it might be more beneficial to reduce the binary size and skip texture compression. Additionally, not using the transcoder can lower the amount of memory required to run your game.
Expand Down
Loading
Loading