Skip to content

C++ and Blueprint reference

The C++ and Blueprint types a game uses to open documents and react to them. The page an entry links to has an example. In C++, add the module named for a type to your Build.cs (Project setup) and include its header.

The viewport subsystem

The object a game talks to is UArcRmlViewportSubsystem (module ArcRmlUI, header Host/ArcRmlViewportSubsystem.h). Each local player has one. In C++ call LocalPlayer->GetSubsystem<UArcRmlViewportSubsystem>(); in a Blueprint place the Arc Rml Viewport Subsystem node (palette: Get ArcRmlViewportSubsystem) and connect its PlayerController input. A function marked (C++) has no Blueprint node. Documents describes how opens and closes queue.

Function What it does
OpenDocument(Document, CloseAction) Opens the document on its layer; returns false for an empty path, an unreadable head (the document's <head>, where its layer, input mode and view models are declared) and while the player's world is being cleaned up. CloseAction is an optional Input Action whose keys also close the document.
OpenDocument(Document, Init, CloseAction) (C++) The same, with an Init function that runs on every open that activates the document, after its view models exist and before it is shown.
PreloadDocument(Document) Preloads the document: queues it to be loaded in the background before it is opened; asking again for the same path does nothing.
CloseDocument(Document, Reason) Closes the document; Reason defaults to Api.
DiscardDocument(Document) (C++) Destroys the parked view of a closed keep-alive document.
IsDocumentOpen(Document) (C++) True while the document is open; a document playing its leave transition counts as not open.
PostBack(Document) Sends Back to the document's view. Returns false when the document is not open, is leaving or hidden, or takes game input only (its input mode is game). See Events.
SetViewModel(Document, ModelName, ViewModel) Assigns a view model to a live declaration of the document, by name; returns false when the document declares none of that name. See View models.
SetViewModelByClass(Document, ViewModel) The same, choosing the declaration by the view model's class; returns false unless exactly one declaration takes it, one whose source is manual or that is settable.
GetViewModel(Document, ModelName) The view model of the shown document with that name, or null. Pure.
GetLayerDocuments(Layer) The open documents of a layer, bottom to top; a frame is listed by its own path.
GetTopDocument(Layer) The last of those, or an empty reference.
GetShownTab(Frame) The tab a frame shows, or an empty reference when the frame is not open. See Frames and tabs.

Three events, assignable in Blueprint, are described under Documents:

Event Parameters
OnDocumentActivated Document
OnDocumentDeactivated Document
OnDocumentClosed Document, Reason (EArcRmlCloseReason)

Open a document from a Blueprint

The Open Document for Player node (C++ UArcRmlAsyncOpenDocument::OpenDocumentForPlayer, module ArcRmlUI, header Host/ArcRmlAsyncOpenDocument.h) opens a document for a player in a Blueprint. Its inputs are Owning Player (OwningPlayer, the player's player controller), Document and an optional Close Action. Its outputs are two execution pins, each with a Document pin: Before Activate fires at the Init moment above, and After Activate fires once the open has succeeded. See Documents and Blueprint view models.

Document widget

UArcRmlDocumentWidget (ArcRmlUI, Host/ArcRmlDocumentWidget.h) is a UMG widget that shows one document. Its Blueprint members (Document, SetViewModel, ReloadDocument, OnOpenRequested, OnCloseRequested) are in the category ArcRmlUI|Document Widget. See A document in a UMG widget.

UI scale

UArcRmlUISettingsSubsystem (ArcRmlUI, Host/ArcRmlUISettingsSubsystem.h) is a game instance subsystem, C++ only (no Blueprint node), not created on a dedicated server. SetUIScale sets Application Scale and SetMaxUIAspectRatio the aspect cap (default 16:9, 0 for no limit); GetUIScale and GetMaxUIAspectRatio return them. Neither value is checked or saved; the project's Application Scale comes back when the game instance ends. See Screen size, cursor and players.

Types

Type Module and header What it is
FArcRmlDocumentRef ArcRmlUIData, ArcRmlDocumentRef.h A Blueprint struct with one Path string: the package path of a document.
FArcRmlImageRef ArcRmlUIData, ArcRmlImageRef.h A Blueprint struct with one Path string: the package path of an image. A view model field of this type reads as its Path text in a document (Data binding).
FArcRmlStructList ArcRmlUIData, ArcRmlStructList.h A keyed list of struct rows of one row type for a C++ view model, sending only the rows that changed. See Data binding.
EArcRmlCloseReason ArcRmlUI, Host/ArcRmlCloseReason.h Why a document closed: Api, Back, CloseKey, DocumentAction, Discard, Reload, WorldCleanup. Passed to CloseDocument and delivered by OnDocumentClosed (Documents).

Clock

ArcRmlClock::Seconds() (C++, module ArcRmlUIData, header ArcRmlClock.h) returns the seconds since its first call as a double. Store it in a view model as a time stamp; the arcsince transform then gives the seconds from that stamp to now on the clock the document runs on. ArcRml.Clock stops the document's clock in builds that are not a Shipping build (Console reference); the value Seconds() returns keeps running.

Sync Strings from a script

UArcRmlStringSyncLibrary::SyncStrings (editor module ArcRmlUIEditor, header Localization/ArcRmlStringSyncLibrary.h; Blueprint category ArcRmlUI|Localization, so an Editor Utility Blueprint can call it) and its editor Python form unreal.ArcRmlStringSyncLibrary.sync_strings(package_paths) do what Sync Strings does in the Content Browser for the given document package paths and return the errors as <path>(<line>): <message>, or <path>: <message> when there is no line. See Localization.