Slate Designer with C++ code

Hi, I read some old threads about the need for a visual designer for slate - what do people use now? Is the UMG designer what people are using for this?

I am writing a C++ plugin with some complex UI and was wondering if there is a designer that produces C++ code or loads/saves an xml for C++ plugins?

Or should this be done in the UMG editor and use blueprints to call the C++ code?

I’m finding it hard to get uptodate info on this, and many of the slate examples aren’t very clear.

This is the way to combine UMG and C++. Usually either by calling a native version of UUserWidget parent class function or by calling some function on a UObject accessible by the UI that is implemented in native code.

Thanks for the reply - but I was wondering - for a C++ plugin that has a complex UI, that I was creating in C++ with slate - is there a way to design visually and get slate c++ code, or is this just not done and UMG is used for all plugin UIs?

All editor UI has to be written in pure Slate - no way to design it visually sadly.

Without derailing this topic, the UMG to C++ combination is possibly one of the most infuriating things about UE4. There’s no decent way to configure widgets from C++ because UMG widgets aren’t exposed at compile time. Either that or I’m doing it wrong, there’s such a large lacking of documentation for it.

The focus of UMG is to make it possible for non-programmers to make UI. If you want to write it purely from C++ just use Slate directly. The way we use UMG internally is to keep the UI code in blueprint, and all the game code code in C++, either through a subclass UUserWidget, or through a model object that knows nothing about UI.

I have made a little editor to help me with my plugin UI design - not very usable now, just means I can design visually and output C++ code for my plugins. Does anyone think this would make a useful plugin for the community - a slate visual designer that outputs C++ code you can drop into a C++ plugin?

I’m not sure if I could do my plugin with blueprints, but I’m a programmer and I find blueprints a little frustrating.

In another thread, Extending UUserWidget, I’m trying to extend some of the UMG controls by inheriting from them. For example, inheriting from Button, I’d like to add a TextBlock as a child widget. Unfortunately UE4 Editor crashed and I had to remove it from my source and compile externally before I could open the project again.

Should UMG controls and the editors behave in similar fashion to what Visual Studio does?

Do you have an example you can share that shows the use case I described? That is, inherit from Button, and add a TextBlock to it?

Alright, thanks for clearing that up. Personally, I’d love to see UMG be a little more compatible with C++.

What do you mean by this exactly? Can you give an example of what you would like to be able to do, but can’t?

It’s clearly the case that UMG was made with blueprints in mind, but I think you can access the widgets at the C++ level if you need to.

Essentially I wanted to move, size and add to widgets from C++. I know you can expose the C++ to the extended userwidget but it just didn’t seem like the right solution.

I don’t see why you can’t do this. After all, the blueprint stuff always goes through C++ code anyway.

UPanelWidget, for example, has methods for adding children.

If you don’t want to use the designer, you can construct the widget tree from scratch. If you want to make use of the designer but also do things in C++, you could (I expect) use UUserWidget::GetWidgetFromName to get specific widgets in the tree. Alternatively you can expose a UPROPERTY on your UUserWidget-derived class (of type UButton*, for example) and assign one of the widgets you placed in the designer to it, from within the widget blueprint Construct event. Then you call a C++ initialization function to do all the work.

A bit unwieldy maybe, but if you really want to set it all up from C++, I’m sure you can do.