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"

UMG Blueprint to C++ Conversion

Hello Friends,

I'm currently trying to convert my UMG Blueprint Widget into a C++ class and was wondering what the best route would be to do this? To provide some context, I have a UMG blueprint that has multiple overlays, a background image, and a slate brush under a canvas panel. I use an EventGraph to update the position of the slate brush relative to the player controller world position. I also have a OnMouseButtonDoubleClick that gives me the position of the mouse relative to the minimap all in blueprints.

Does anyone have any recommendations for what class I should go with to convert this into C++? Should I create a Blueprint Function Library to create one large Widget node and expose that to the UMG event graph. Or should I go with the Slate Widget class and try to construct everything and expose all functions without UMG? I'm a bit of a UE4 C++ noobie if you can't tell, and I would love the advice!

Thank you for your time!

Product Version: UE 4.21
more ▼

asked Apr 01 '19 at 05:39 PM in C++ Programming

avatar image

6 1 2

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

1 answer: sort voted first

I've found that when creating menu systems, the best approach is to create the base class in C++, and then parent the blueprint UMG widget to that.

I'd create a C++ class with its parent as a UUserWidget (class MY_API UMyWidget: public UUserWidget). In here, you can create the tick function (NativeTick for Widgets) and do you tick logic in here instead of the blueprint.

For the actual Background Images, overlays and other widgets, I'd leave them in the Blueprint as it is much easier to manager there. If you do want references to them in C++, I found the best way is to create a variable with the same name in code and use "meta = (BindWidget)". This will link the blueprint variable to the code variable.

 UPROPERTY(meta = (BindWidget))
 class UCanvasPanel* MyCanvasPanel;

You can also look at hooking up the Mouse events on the widgets if you like, but this can be more in-depth and is probably easier to get to grips with in the blueprints if you are quite new to the UE4 C++. The API reference to the C++ function is here though: http://api.unrealengine.com/INT/API/Runtime/UMG/Blueprint/UUserWidget/OnMouseButtonDoubleClick/index.html

more ▼

answered Apr 01 '19 at 06:37 PM

avatar image

1.9k 53 40 200

avatar image anoxxi-dis Apr 01 '19 at 06:38 PM

Thanks for the info Dune! I'll give this a try

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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