The GUI Editor

Creating GUIs With Ease
Introduced in Babylon.js 5.0, the GUI Editor is a visual editor for building complex and beautiful graphical user interfaces. Traditionally, Babylon GUIs has to be constructed using code, which could be a tedious and confusing process. The GUI Editor lets you see the interface as you're assembling it, and makes it easy to manipulate all the parameters of each control.
You can access the GUI Editor here: https://gui.babylonjs.com/. The GUI editor can also be opened in a pop-up window from the inspector, allowing you to edit a GUI inside a scene and see your changes propagate back instantly!
This document will walk you through the editor and its capabilities and should help you quickly start creating your own GUIs. If you're not familiar with the GUI system in Babylon.js and would like to learn more, you can read all about it here: Babylon GUI Documentation
Getting Familiar With The Layout
Let's start by familiarizing ourselves with different parts of the editor.
Header Bar

The Header Bar provides several handy items to help you navigate and manage your GUI creations.
Hamburger Menu

The hamburger menu provies some basic helpful scene management options, including saving and loading your progress locally, saving and loading your progress to the snippet server, and a quick 'help' link to access the Babylon.js GUI documentation.
Select (S)

The select button allows you to select different GUI controls within your scene.
Pan (P)

The move button allows you to pan around the GUI by clicking and dragging. You can also use the middle mouse button, or hold space and drag, to pan around your GUI.
Zoom (Z)

The zoom button allows you to click on the canvas and drag to zoom in. You can also hold ALT+click to zoom out.
Fit To Window (F)

When pressed, the Fit To Window button will snap the zoom and panning back to the starting position, where the entire canvas can be seen. If you have any controls selected, Fit To Window will crop the viewport around those controls.
Toggle Guides

The Toggle Guides button will display boundary lines for all of the GUI elements in your scene.

Artboard Color
Allows you to change the background color in the region outside of the canvas.
Responsiveness and Resolution
You can either specify a specific resolution for your canvas in pixels, or you can turn on responsive mode, which lets you easily swap between common resolutions such as mobile and desktop. Responsiveness is an editor-only concept, it does not affect the exported GUI.

Hierarchy Panel

The Hierarchy Panel is an organized list of all of the GUI controls that you've added to the canvas. You can select controls from this list as well as click and drag to parent and unparent them.

The order of controls listed in the Layers Panel reflects the z-order of the scene with the elments at the top of the list having a z-order that will render them on top of elements towards the bottom of the list.
If a control is placed behind another control in the scene, and it has a lower z-order, the only way to select it is from the hierarchy.
The 'eye' icon will show/hide controls on the canvas.

Controls Bar

The Controls Bar allows you to create GUI controls, such as a text box, rectangle, grid, etc. Each icon in this bar can be clicked on to add a specific GUI control to your canvas. You can also drag and drop these icons into either the canvas or the hierarchy tree to add it to the scene.
If you'd like to see a full list of supported GUI controls in the editor, click here.
Canvas

The Canvas is the main play area of the tool. The canvas contains the artboard where you can add controls, select controls, and click and drag controls to move them around. This panel represents a WYSIWYG (what you see is what you get) experience to how GUIs will show up in Babylon Scenes.
The checkerboard area reflects the content that will actually be visible in your scene when you load the GUI in. Note that controls can be moved outside of that region, which may be helpful if, for example, your UI has components that animate on and off-screen.
Handy Keyboard Shortcuts
There are several handy keyboard shortcuts that you can utilize in the GUI Editor.
General Navigation:
- S = Select Mode
- P = Pan Mode
- Z = Zoom Mode
- F = Fit to Window
- G = Toggle Outlines
- CTRL+A = Select All
With a GUI Control Selected:
- CTRL+C = Copy
- CTRL+V = Paste
- CTRL+X = Cut
- Delete/Backspace = Delete
Control Properties Panel

The Properties Panel will change based on which controls are selected selected to reflect the properties specific to those controls. This is where you'll find all of the properties and can fully customize each individual element of your overall GUI.
For example here is how to change the name of a GUI.

For properties which can be expressed in either pixels or percentage values, you can click on the unit button next to the input to toggle between unit types. The existing value will be converted into the equivalent value in the other unit.

Note: While using the GUI Editor to create a GUI and modify its properties, these properties can later be changed in the Babylon.js scene code. So you have full control over all of the GUI Control properties at creation time as well as runtime!
Special Properties for Grid Control
Grids are a powerful tool for building complex UI layouts. Grids are helpful for setting up the foundation of your design. Just like in code, in the GUI Editor you can define your grid's row and column definitions. You can add and remove rows and columns, as well as modify the sizes using either pixels or percent.

You can then add them to the grid through parenting in the layers panel. Once parented, you can modify a control's grid cell by selecting the control and editing the newly added property at the bottom of the Properties Panel.

Note: the zOrder of each control is determined by it's position in the hierarchy tree, and can be reordered with normal dragging regardless of which grid cell it belongs to.
Saving GUIs Out Of the Editor
You can save your GUI creations from the Editor in two different ways, locally or on the Babylon.js Snippet Server.
Saving Locally
Saving locally will download a .JSON object of your GUI to your local machine. This can then be either loaded back into the editor later for future use, or can be hosted somewhere of your choosing and then loaded directly into your Babylon scene. See Loading GUIs Into The Playground
You can save locally by selecting the 'Save' button in the hamburger menu:

Saving To The Snippet Server
Just like all Babylon tools, you have the option of saving your GUI creation directly to the Babylon.js snippet server. Saving in this manner saves the .json object to a Babylon.js server and provides a simple URL hash back for you to reference in the future. You can then load your GUI back into the editor by using this unique hash, or you can use the hash to load your GUI directly into the Babylon scene. See Loading GUIs Into The Playground. Saving to the snippet server will also update the browser's URL to point to that snippet (e.g., gui.babylonjs.com/#aaaaaa)
You can save to the snippet server by selecting the 'Save To Snippet' button in the hamburger menu:

Loading GUIs Into the Editor
You can load your GUI creations into the Editor in two different ways, locally or from the Babylon.js Snippet Server.
Loading locally
Loading locally will prompt you to upload a .JSON object of your GUI into the Editor.
You can load locally by selecting the 'Load' button in the hamburger menu:

Loading From The Snippet Server
Loading from the snippet server will take a unique hash of a previously saved GUI and load it into the the Editor.
You can load from the snippet server by selecting the 'Load From Snippet Server' button in the hamburger menu:

Using GUIs From The Editor In Your Scene
It is very easy to load your saved GUIs into your Babylon.js scene and modify them. Here are a few handy examples:
Load From .JSON Object
You can load a GUI into your Babylon scene from a saved .JSON file somewhere on the web like this:
let advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("GUI", true, scene);let loadedGUI = await advancedTexture.parseFromURLAsync("https://doc.babylonjs.com/examples/ColorPickerGui.json");
Load From Snippet Server
You can also load a GUI into your Babylon scene from the Snippet Server like this:
let advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("GUI", true, scene);let loadedGUI = await advancedTexture.parseFromSnippetAsync("#MMWSUI");
Load in Fullscreen Mode
You can load your saved GUI as a fullscreen GUI that's overlayed on top of your entire scene like this:
let advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("GUI", true, scene);let loadedGUI = await advancedTexture.parseFromSnippetAsync("#MMWSUI");
Further Information about fullscreen GUIs can be found here: Fullscreen GUIs
Load in Texture Mode
You can also load a saved GUI as a texture that can be used like any other texture in your scene. Here's an example of using a loaded GUI as a texture for the material of a mesh:
let screenUI = BABYLON.GUI.AdvancedDynamicTexture.CreateForMeshTexture(device.screen, 2048, 2048, true, false);screenUI.parseFromSnippetAsync("#WFL50L");
Further information about GUIs as in-scene textures can be found here: GUIs as a Texture
Changing GUI Control Properties In Your Scene
After loading a saved GUI into your scene, you can easily access the properties of your GUI Controls.
You can access an individual control by name like this:
let backgroundBox = advancedTexture.getControlByName("BackgroundBox");backgroundBox.background = "blue";
A more sophisticated example can be found here:
Game Menu DemoPlayground Templates
You can also find quick access to the common lines of code needed to load GUIs into your scene, through the playground templates.
Supported Controls
Here is a list of supported GUI controls available in the GUI Editor:
Icon | Control Name | Further Information |
---|---|---|
Icon ![]() | Control Name Rectangle | Further Information Rectangle Documentation |
Icon ![]() | Control Name Ellipse | Further Information Ellipse Documentation |
Icon ![]() | Control Name Stack Panel | Further Information Stack Panel Documentation |
Icon ![]() | Control Name Grid | Further Information Grid Documentation |
Icon ![]() | Control Name Scroll Viewer | Further Information Scroll Viewer Documentation |
Icon ![]() | Control Name Line | Further Information Line Documentation |
Icon ![]() | Control Name Text Block | Further Information Text Block Documentation |
Icon ![]() | Control Name Input Text | Further Information Input Text Documentation |
Icon ![]() | Control Name Input Password | Further Information Input Password Documentation |
Icon ![]() | Control Name Image | Further Information Image Documentation |
Icon ![]() | Control Name Display Grid | Further Information Display Grid Documentation |
Icon ![]() | Control Name Text Button | Further Information [A Button with a Text Block as a Child] (https://doc.babylonjs.com/divingDeeper/gui/gui#button) |
Icon ![]() | Control Name Checkbox | Further Information Checkbox Documentation |
Icon ![]() | Control Name Radio Button | Further Information Radio Button Documentation |
Icon ![]() | Control Name Slider | Further Information Slider Documentation |
Icon ![]() | Control Name Virtual Keyboard | Further Information Virtual Keyboard Documentation |
Icon ![]() | Control Name Color Picker | Further Information Color Picker |
Demos
Check out additional demos here:
Full Color Picker Demo