Overview

In this document we’ll use the terms binding and UI scripting interchangeably.

  • To register for an event received on the C++ side, you have to use one of these methods:
    CohtmlComponent->GetView()->RegisterForEvent(...)
    CohtmlComponent->GetView()->BindCall(...)
  • To register for an event received by JavaScript you need to call the engine.on function:
    engine.on('Click', function()
    {
        console.log('Click called');
    });

In both cases, the view you must wait until the View is ready for bindings, and then attach your event handlers.

UI Scripting via Blueprints

Prysm supports scripting the UI via Blueprints. This allows developers to expose game objects to the UI to populate the interface and trigger actions from the UI, like starting a new game when the player clicks “Start game” in a menu.

With Prysm you can script the whole UI via Blueprints without any C++ code.

Developers can trigger events in the UI JavaScript code via Blueprints, or expose primitive types and any UObject to the UI.

In the following sub-sections we’ll introduce a small example that shows two-way communication between Blueprints and the UI in JavaScript. The example is available in the sample game (CoherentSample).

  • JavaScriptInteractions - A guide on different ways to achieve communication between the game and the UI
  • DataBinding - A feature that synchronizes the state of your UI with the state of the game, without the need for any form of JavaScript