Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Authoring Workflow

Porrith Suong edited this page Jan 4, 2021 · 8 revisions

Authoring UI is aimed to be seamless. You author your UI as usual.

  • Create a canvas
  • Create children UI elements
  • Parent and group elements together

The major difference is where the UI is supposed to live. Instead, the UI lives in a subscene. This is so that the GameObjects are converted to their entity format.

Subscenes

To create a subscene, right click in your Hierarchy Window and select, "New Subscene." You can create an empty subscene now and move GameObjects to the subscene later or create subscenes from a selection of GameObjects.

subscenes

Subscenes convert your GameObjects into an Entity on a background thread so not all Unity APIs are supported.

Baking Data

One of the caveats of the using UGUI and Unity's subscenes is that data needs to be embedded into MonoBehaviours. Because UGUI needs to always update to keep the data relevant, the data only lives when the subscene is opened. To work around this, we bake transform data to a ScriptableObject called the BakedCanvasData and we read this data on conversion.

Creating the BakedCanvasData Scriptable Object

Right click in your project view and select UGUIDOTS -> BakedCanvasInfomation . This will create a ScriptableObject where we can register and copy the transform data.

Baking Transform Data

Add the BakedCanvasDataProxy to your Canvas. Drag your Scriptable Object into the Baked Canvas Data field.

baking canvas

When first adding the component, you will get a warning stating:

The Canvas' transform hierarchy has not yet been baked.

Click the Bake Canvas Hierarchy button to bake the data to the Scriptable Object. Canvases that are not baked will throw a warning message in the Console stating that conversion will be skipped. All baked canvases will store the Instance ID at that point in time. This is how each canvas is mapped.


When baking infomation, make sure that your screen resolution matches your ideal reference resolution that you are working with. This ensures that your initial transform has a 1:1 ratio of what you are currently editing in.

So if your reference resolution is 1920 x 1080, ensure your game view has a resolution of 1920 x 1080.


Updating Baked Information

If your structural hierarchy changes, it's highly recommended that your BakedCanvasData is updated with the new structure of the hierarchy. In this case, you would click the Update Baked Canvas button, so that the representation at the Instance ID is updated.

Removing Baked Information

Click the Remove Baked Canvas data to remove the baked information from the Scriptable Object. This will set the Instance ID to 0, which is an invalid ID.

Clone this wiki locally