x

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"

Dynamically creating UMG Widgets?

Hey guys, so I've got to the stage where I want to start working on making my conversation system into a UI, opposed to text in the console.

My aim is to create a text box for each choice in a conversation, much like most bioware games, with a choice wheel.

All I need is to be able to create UMG widgets on the players HUD that will let me create a list of text boxes, often 1 - 3, vertically in the centre of the screen.

I've already got a custom UIWidget for the text box and it's text is bound to a variable on my custom class. I just need to be able to create and remove them in C++.

I have a blueprint of the custom UIWidget but I don't know how I would go about placing it on the players HUD and making them stack on top of each other?

Product Version: Not Selected
Tags:
more ▼

asked Mar 19 '15 at 09:48 PM in C++ Programming

avatar image

Belven
90 19 35 46

avatar image Katianie May 22 '15 at 04:52 PM

I have the same problem

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

1 answer: sort voted first

Not sure I understand the question, but if it's just how to create UMG widgets from C++ then in the class you want to create from add:

 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
 TSubclassOf<UYourCPPBaseWidget> WidgetTemplate;

In the editor set WidgetTemplate to your Blueprint Widget which derives from UYourCPPBaseWidget.

Then to create the widgets from C++:

 UYourCPPBaseWidget* Widget = CreateWidget<UYourCPPBaseWidget>(GetWorld(), WidgetTemplate);
 Widget->AddToViewport();

I don't know what you mean by stacking though.

more ▼

answered May 22 '15 at 06:10 PM

avatar image

NeverContent
6 3

avatar image Katianie May 22 '15 at 08:21 PM

The problem I have with what you wrote is that WidgetTemplate is always null. So to fix that I load the blueprint via c++ with this line

 myInventoryWidgetType = StaticLoadClass(UInventorySlot::StaticClass(), NULL, TEXT("/Game/FirstPerson/UI/InventorySlotBlueprint.InventorySlotBlueprint_c"));
avatar image Belven May 22 '15 at 09:44 PM

By stacking I meant that the widgets would go underneath each other, so like a menu of buttons. that's all.

(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