Setting Up Widget Elements in Constructor of UUserWidget
I'd like to make a constructor for a UUserWidget in which I add some widget elements like a vertical box to the widget tree that can be edited in the UMG view but still called from C++, as you may add a component to an actor through C++ in the constructor and edit it in the viewport. This seems like the most natural way to work with UMG from C++, but I'm stumbling all over it! Is this possible? How would I do it?
asked Mar 01 '17 at 05:48 PM in C++ Programming
I have an answer from Unreal!
"it sounds like you're looking for BindWidget, a property metatag that lets you define a UMG widget property in C++ and automatically bind to the instanced created with the same name in the UMG editor. We don't have much documentation for the tag just yet, but I'll walk you through it.
On your C++ class which inherits UUserWidget, define UProperties for any widgets you want as follows:
Then, when you create a UUserWidget using your derived class in the UMG editor, you'll create a panel and name it MyPanel, and we'll automatically bind this c++ property to the created widget behind the scenes. Note that you'll see a compile error if no widget MyPanel is found or if it's a different widget class. Alternatively, if you don't want to see a compile error and want the implementation of the property to be optional, you can declare it as follows:
answered Mar 01 '18 at 07:02 PM
I've not yet found a way to do this, so far everything seems to point at can't be done, but nothing with a staff member confirming that's the case and whether it's intended. Here's another thread on the same question. https://answers.unrealengine.com/questions/521224/request-improve-inheritance-in-userwidget.html
answered May 06 '17 at 10:11 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here