UI

UI

UI Editor

Unity has UI directly in the scene and Lumberyard stores the UI in a file separate from the level. Storing in a separate file allows the UI to be loaded dynamically, as well as having the level and canvas be easier to navigate. For the UI to appear in the level, an entity must hold a reference to the canvas as well as determine when the canvas is loaded (at start or on an event).

Lumberyard uses a separate UI Editor to edit the canvas.  Because the UI Editor is separate from other entities in Lumberyard, the inspector cannot reference other entities in the level but only the elements located on the canvas. Communicating with entities located in the level requires additional work through scripting. Unity UI has the advantage in that UI GameObjects can directly connect with non-UI GameObjects. Lumberyard requires entities to subscribe to the entity which contains the canvas, then entities within the canvas can message the parent entity.

Having the canvas built into the scene also allows Unity to achieve 2D games with less struggle. Although Lumberyard doesn’t have a dedicated 2D developer mode, 2D games are still possible through the UI Editor, but level components cannot be accessed.

Once in the UI Editor, the workflow for artists is similar to that of Unity. Entities (referred to elements in the Lumberyard canvas) are similar to canvas GameObjects in Unity, with defaults like image located within the slice library. The anchor system is also similar to Unity, where entities can be manipulated to anchor to certain parts of the canvas dependent on the screen resolution. Importing images to both engines is the same flow, however importing fonts is different since fonts are available in every project of the engine. UI canvases in Unity can be made prefabs however aren’t required to be, but within Lumberyard the canvas must be saved into a file. Previewing UI is possible in Lumberyard unlike Unity, a canvas can be previewed as if the game was playing with real-time UI effects, without playing the game itself.

UI Transform Comparison

 

For a canvas to be positioned in the level, Unity’s world space render mode option, the Lumberyard canvas must be set to render to texture with a valid render target. Unity has a concept of render targets which is storing the display of a camera to an image, in Lumberyard it is the same concept and for UI it is as though the camera is only displaying the UI. The render target is then associated to a material, which can be assigned to a mesh in the level.

UI Canvas Properties Comparison

Scripting Interface

Developing UI scripts in Lumberyard is similar to that of Unity. There is a dedicated set of components to attach to the entities and a separate set of scripting functions for only UI. Although in Unity you are required to add in the UI library, in Lumberyard the functions, classes, and events for UI are available, although not necessarily useful, in any script. A continued difference with Unity and Lumberyard scripting is with respect to obtaining another entity and sending messages between entities. In Unity, the UI GameObjects can communicate with any object in the scene because the objects are located within the same save file, however because Lumberyard’s UI entities are located within the UI canvas the entities can only communicate with entities in that canvas. This is the same logic to Unity’s prefabs not being able to store references to scene object, because the canvas is a separate save file of data to the level.

Sidebar