-
Notifications
You must be signed in to change notification settings - Fork 9
Using the Coherent UI plugin
There is a sample flow graph in <Code>/CoherentUI_CryEngine3/samples/GameSDK/Levels/Singleplayer/ForestCOUI/CoUIFlowNodes.xml.
The easiest way to use it is to open the sandbox (editor), load the provided ForestCOUI level and import the flow graph into an entity. The scene is already set up and the flowgraph adds UI and web surfaces.
As an example, we'll import the sample into CoherentBreakableEntity's flow. Select the CoherentBreakableEntity entity and click on "Create" in the Flow Graph section of the rollup bar.
From the Flow Graph window, select File -> Import... and import CoUIFlowNodes.xml. Exit the Flow Graph window, save the level and export it to the engine (Ctrl+E). Now the flow graph will be used in the GameSDK, too.
The rendering of the Coherent UI surfaces is done in a special way that is the only feasible one when using the FreeSDK. Basically, we setup a material for the entity we want to cover with a Coherent UI surface and do not use that material for anything else since its texture will be overridden. The material needs to have a texture that does not have any mip levels, or you may encounter strange blending artifacts. You can make such texture in DDS format using the DirectX texture tool that comes with the DirectX SDK.
The Coherent UI plugin comes with a few sample materials that are setup for usage with Coherent UI. Note that it is important that the texture used for a Coherent UI material should have the same dimensions as the Coherent UI View that will be overriding it. Otherwise your View will be displayed improperly.
After setting up the materials on your entity, you need to add a flownode to display Coherent UI onto it. The 2 essential nodes that you are going to use are the CoherentUI_Plugin:OutputEntity (for 3D objects) and the CoherentUI_Plugin:OutputHUD for the Camera.
A list of the available flownodes follows:
Renders a Coherent UI View on an entity
Inputs
-
ActivateActivate the node -
UrlInitial url to display on the view -
WidthWidth of the view in pixels -
HeightHeight of the view in pixels -
TransparentDefines if the view should be transparent or not -
ClickableDefines if the view should support click-through queries -
MeshGeometry object for calculating correct click coordinates on the entity -
SharedMemoryDefines if the view uses shared memory for the rendering data transport or shared textures
Outputs
-
ViewIDId of the view for further use (e.g. for the TriggerEvent node)
Renders a Coherent UI View on the HUD
Inputs
-
ActivateActivate the node -
PathPath to the html files defining the HUD (e.g. coui://Libs/UI/hud.html)
Outputs
-
ViewIDId of the view for further use (e.g. for the TriggerEvent node)
Handles an event from a Coherent UI View with an optional string and boolean parameter
Inputs
-
ActivateActivate the node -
ViewIDId of the view as obtained from one of the output nodes -
EventThe event name
Outputs
-
Arg1String argument received from the view (optional) -
Arg2Boolean argument received from the view (optional)
Triggers an event on a Coherent UI View with an optional boolean parameter
Inputs
-
ActivateActivate the node -
ViewIDId of the view as obtained from one of the output nodes -
EventThe event name -
Arg1Boolean argument to be send to the view (optional)
Triggers an event on a Coherent UI View with up to four float parameter
Inputs
-
ActivateActivate the node -
ViewIDId of the view as obtained from one of the output nodes -
EventThe event name -
Arg1First float argument to be send to the view (optional) -
Arg2Second float argument to be send to the view (optional) -
Arg3Third float argument to be send to the view (optional) -
Arg4Fourth float argument to be send to the view (optional)
Triggers an event on a Coherent UI View that receives the JSON encoded game tokens
Inputs
-
ActivateActivate the node -
ViewIDId of the view as obtained from one of the output nodes -
EventThe event name (default: GameTokens)
Switch input between player and Coherent UI. When enabled, all input is sent to Coherent UI and the mouse cursor is displayed.
Inputs
-
ActivateActivate the node -
EnabledBoolean argument. True enables input to Coherent UI, false disables it