3Ducttapes(); Yvo von Berg | CG Toolsmith blog | C++, Python

Tycoon C++ UI Slate update

Did some work on the UI today.

Slate framework

The current UI framework from Unreal is called Slate. Slate is a wrapper around the Chromium Embedded Framework (CEF). (The engine of Google Chrome). That means that Slate is using web technology to draw the UI, take a look here: wikipedia

Did you know that Unity, Evernote and many game launchers are using the CEF framework?

Slate vs UMG (Unreal Motion Graphics)

You might have used UMG widgets inside Unreal before, UMG is another wrapper above the slate framework. UMG widgets are made with a visual editor and are saved as binary assets in your game project. This might work fine for most simple game menus, but keep in mind that you may need to bind these events using BP to C++. That operation might not scale or perform that well for bigger projects.

Back to slate: slate docs


Work in progress

For my plugin I wanted to populate a new tab in the ‘modes’ window. In unreal this is called an ‘editor mode toolkit’. You can inherent your UI class from: FModeToolkit Take a look at plugin examples for editor modes.

The slate syntax looks like this:

// Create a new widget
// New 'slot' / row
+ SVerticalBox::Slot()
// Add some properties
    // Inside this row, make a new widget
        // Another one, image this time
                FVector2D(214.0f, 40.0f)

You can also make methods to generate new widgets, this is how I created the buttons: Make sure to set the type to be a ‘smart’ shared reference. -> smart pointer lib

TSharedRef<SWidget> FTycoonToolEdModeToolkit::MakeExternalButton(FString label)
    return SNew(SButton)
        .ButtonStyle(FCoreStyle::Get(), "NoBorder")
            .Image(LoadImage(label + "." + label))
        // Bind method to the click event of this button

Debugging UI in Unreal

Sometimes things don’t work properly, or you are just curious about some cool UE4 button. In that case you can use the Widget Reflector Tool, you can pick any widget and inspect it’s properties.

Next steps:

  • Still have to learn how sliders work.