Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Using a UMG HUD with c++ game mode and player character


I am starting to use Unreal Engine, and I wish to use a HUD for a small game.

I have seen that using UGM is easier to draw HUDs, but the rest of my project is in C++ I can't find how to use my blueprint HUD which is a UUserWidget with my C++ project.

While searching, I found this link : https://wiki.unrealengine.com/UMG,_How_to_extend_a_UUserWidget::_for_UMG_in_C%2B%2B.

I used it to create my own subclass of UUserWidget, but now, I don't know how to get this widget to actually be used by my C++ HUD subclass.

Thank you.

Product Version: Not Selected
more ▼

asked Feb 23 '15 at 03:11 PM in C++ Programming

avatar image

16 1 2 2

avatar image IanBreeg Feb 24 '15 at 08:28 AM

You can use CreateWidget and AddToViewport() to display your widget. Consider this setup (the code below might contain some syntax errors because I don't have any docs or Visual Studio at the moment to check it, but you get the idea):

.h file

 TSubclassOf<YourCustomWidget> YourCustomWidgetUIClass;
 YourCustomWidget* YourCustomWidgetUIWidget;

.cpp file

 YourCustomWidgetUIClass = LoadClass<YourCustomWidget>(..., TEXT(path_to_your_widget_in_content_browser), ...);
 YourCustomWidgetUIWidget = CreateWidget<YourCustomWidget>(GetWorld(), YourCustomWidgetUIClass);

"path_to_your_widget_in_content_browser" can be something like "Game\UI\MyWidget.MyWidget_C".

Hope this helps :)

avatar image Borkatator Feb 24 '15 at 08:37 AM

Thanks, I might not be able to try this right away, but i'll keep you updated as soon as possible !

avatar image Pelangi Aug 16 '16 at 12:52 PM

What if we don't want to use any blueprint widget? So every widget is created purely in C++. How can we do that?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question