UMG without blueprints

I don’t really like using the blueprint system and am therefore trying to figure out how I would use UMG without it.
But I’m having a hard time :slight_smile:

What I imagine is coding all the logic and set up in c++ and then in UMG link mostly just visual parts.
Is this a viable option, and/or is this viable in the future?

Or else if I want full control over all my elements in c++ would you recommend using slate instead?
I’m a little lost here on what is what, there is a lot of documentation on BP for UMG but little to none in context of c++.
And the sample games mostly use slate for UI

I would be interested in hearing anyone’s take on this as well-I have all of my dialog systems and string handling finished in C++, and it would be incredibly handy to build a speech bubble in UMG and just control visibility + EditableText text through code.

You can extend Widget with C++ and create functions and variables there, just like you would do with Blueprints. (There are some threads about that, but i don’t have the time to search them right now)
A lot of stuff can be done in C++ like that. But you won’t get away from the Event Graph completely i guess.

Thanks Exi, I think I’ve seen those threads, it seems a very clumsy way to work right now…
I’ve scouted for all I could find, but there seems little escape from blueprints.

About my understanding right now, correct me if I’m wrong…

The Canvas is what all HUD and UI gets draw on,
Slate is a system designed to help with UI systems, kindof like WPF or winforms.
UMG is a wrapper for slate that gives it a visual UI and visual scripting.

So, if I want full control I am probably best off making my own UI System and directly drawing to the Canvas?

The Canvas is the old System. You may only want to use this for testing. Slate is the language behind UMG like c++ is the one behind Blueprints.

To get fully controll, you would learn slate and just ignore UMG. But slate is complicated and not that easy to understand (no real docs and tutorials). Thats why we got UMG which covers ALOT of slate functionality.

To be honest: Avoiding Blueprints in UE4 is wrong. You will want to use them as often as you can, because they make your life a lot easier. And extending a widget with c++ isnt that bad or hard either, compared to learning slate.

If i were you, i would just extend my widgets with c++ logic and thats it.

As eXi said, the whole point of UMG, is to have a visual UI Editor and therefore using Blueprints to bind data to your UI seems to be the most natural approach.
However, you still have the possibility to extend the widget class in C++. I don’t see how this is clumsy.

If you wanted to make UI in C++ (which I think is a terrible Idea), you probably want to straight up use Slate.

Ok, so slate does not use canvas to render anything…

So what about generated content, like a map grid that depends on some map logic, or a dynamically sized inventory, a mini game or console or something like that.
From what I understand now if I use UMG I need to put all the logic that builds these UI setups in blueprint, or is it possible to create generate the UI Setup in C++ and then only place and bind them in UMG?

That is possible as far as i know. You don’t need to put any logic into the eventgraph of the widget. This can be done in c++. All widget functions etc are overridable in c++ and the widget can be added and removed in c++ too.

First off, many thanks for all the help!

So there is a way to directly add a Ubutton to the extended UUserwidget in cpp?
Could someone maybe show me a quick example

Right now the only way I managed to make this work is making new widgets in the editor and add the button there, then adding those to TSubclasses in the extended widget to get access, which lets me create them etc, but this is what seems clumsy to me :smiley:
Would be nice if I could just add a new Ubutton directly in the userwidget in cpp, but its not recognized atm, might be im just missing the right headerfile ofc.

If you want to assemble your UI from Buttons, TextBoxes etc in C++ you’d better use Slate, as Brainshack suggested.
UMG-friendly approach is more like this:
Create variables in c++ widget that UI should display and bind to them from your UMG widget class. If you don’t need any conversions or additional work on these variables it will not create any Blueprint nodes at all.
Create functions in c++ widget that UI should call when buttons are pressed, TextBoxes are changed etc. However your will be creating some event handlers inside your UMG widget, but they will be 2 node long (OnButtonClicked Event -> Call to NativeClickedHandler).
FYI, I am using similar approach in my project and quite satisfied with it.

I would suggest to use UMG to be able to display quickly all your UI with a designer. You will save a lot of time (no compilation compared to slate)
Extend C++ USerWidget and make all your logic in it
bind the C++ function & variable inside UMG - your won’t use a lot of node to do this and it will be fast & readable.

I’m using this as of now and it’s working pretty well.

I worked with slate also before UMG and it’s not user friendly but you have a lot of samples in the different template & Source Code & UT source Code. It’s was painfull to compiled to see the result and that you miss to adjust your widget of 1pt and you need to builg again to see the good result.
Slate is more flexible as of now, but UMG will get to the same level soon.

UMG is best on the animation part as everything is built into the Editor ^^ It also better managed objects behind the scene (like dynamic instance material), the object are not plain C++ but UObject so they are garbaged properly.