Getting Started

Presentation layer can be used to make smooth, complex UI animations

Presentation layer can be used to make smooth, complex UI animations

<aside> đź’ˇ The contents of this guide are covered in Presentation UI Workshop Handout

</aside>

What Is Presentation Layer

The engine has two types of game updates: simulation updates and presentation updates.

Simulation updates occur 16 times per second (by default) and change the game simulation state. Things that are part of the game simulation, such as unit positions and when units take damage, are updated each simulation update.

Meanwhile presentation updates occur whenever a new game frame is rendered, where the exact speed is determined by device performance. This is typically 30 or 60 FPS. Things that are rendered, such as actors and UI objects, are updated each presentation update.

You can see the presentation/simulation update rate with the “Is Dev” flag in the Play Settings Window

You can see the presentation/simulation update rate with the “Is Dev” flag in the Play Settings Window

Presentation Layer Scripting

Presentation layer scripting is a powerful feature that allows you to run scripts and update UI on each presentation update, rather than being locked into the engine’s simulation update. This lets you create smooth UI animations without even using the DCEI Animation APIs.

Keeping all of your UI logic in presentation layer also enforces good coding practice by separating concerns of game logic and UI presentation separate. For theses reasons, it’s recommended that all new game projects create their UI in presentation layer to take advantage of these features.

To access presentation layer scripting, create a Presentation.lua.txt file in your game’s Assets/Scripts/ folder. This Lua file will be the entry point to your game’s presentation layer script, similar to how Trigger.lua.txt is the simulation layer entry point. Similar to Trigger.lua.txt, Presentation.lua.txt will execute automatically when the game is launched.

Note that not all APIs will work in presentation scripts. Any API that affects the game simulation, such as setting a unit’s health, or casting an ability will not work when executed form presentation layer. You can still read simulation values, such as getting a unit’s health.