Skip to content

Working with documents

The loop a designer repeats: edit a document, see it change, check it. The editor reloads open documents on save, so no restart or reopen is needed.

Create a document

In the Content Browser, select a folder and choose Create RML Document under Create File in the + Add menu. The entry shows for the UI/Rml folder of a content root and for a folder that already holds an .rml file, never under UI/Rml/Test/. Pick the kind, then type the name over NewDocument: letters, digits and underscores, not starting with a digit.

  • Screen writes <Name>.rml, <Name>.rcss and Preview/<Name>.json in that folder and opens the document in the editor preview. The document opens on UI.Layer.Menu with input-mode menu and shows the title of its preview data. Its style sheet sets font-family: sans-serif, which draws when Generic Font Families maps sans-serif to a declared family or Fallback Font Family names one (Project setup, Fonts).
  • Component writes <Name>.rml, a component with one prop, label, and <Name>.rcss.

Nothing is written when one of these files already exists.

Edit and save

Edit the .rml and .rcss files in any text editor (the editor preview's Open in text editor opens one) and save. The editor watches the Content folder of every content root. About 0.2 seconds after the last change it compiles the changed .rml and .rcss files and reloads every open document, in the editor preview and in a game running in the editor. A changed .ttf, .otf, .svg, .png or .json file reloads them the same way.

A reload closes each open document and opens it again on its layer. What you see:

  • Lost: the text in fields, the scroll position and other state of the page, and the state kept by keep-alive documents (Keep-alive and preload).
  • Reset: the values of a view model that the document's head creates (create).
  • Kept: a view model that game code assigned with SetViewModel.
  • On an error: a document that fails to compile or read stays as it was, with the rest of its layer. The error shows as described below.

You should see the open document redraw with your change shortly after you save.

The preview

Editor preview shows a document without a game. Its Reload button compiles the document again and reloads the open documents, and Variant switches between the base data and the variants of the document's preview JSON. Changes made in its Bindings panel reload only the documents that read that preview file.

In a game

These console commands exist in every build, except ArcRml.Inspect, which exists outside Shipping builds:

Command What it does
ArcRml.Open <Path> Opens the document on its layer for the first local player.
ArcRml.Close <Path> Closes the open document with that path.
ArcRml.Preview <Path> [Variant] Opens the document with its preview data, or a variant of it; reopens it when it is open.
ArcRml.Inspect [Path] Toggles the inspector for an open document: pick elements in the view, read them in a panel (Debugging layout). Without a path it closes the inspector.

<Path> is the package path, such as /ArcRmlUISamples/UI/Rml/FirstScreen/FirstScreen.rml.

Check a document

Run Validate RML on the changed files; it reports what compiling alone does not. Validation has the Content Browser entry, the console command and the command line run.

Where errors show

  • The editor's Message Log window, ArcRmlUI log: a compile that reports diagnostics for a changed file adds a page with them, and the page Validate holds the validator's result.
  • The preview's Diagnostics panel: the errors and warnings of the open document.
  • In a game outside Shipping, a bar over the viewport lists the errors and warnings of the open documents, and the same lines go to the log category LogArcRmlUI.

Next

  • Validation: what Validate RML reports and how to run it.
  • Debugging layout: pick elements in the view and read them in a panel.
  • Documents: the head, layers and how a document opens and closes.