Thank you Its, thanks to your help so you can take some credit as well.
Cheers!
Thanks for sharing this !
I am sure it will help many people get started with C++ UMG !
PS: Have you considered making a Wiki of this?
Hey glad you liked it :).
I have been meaning to read up on the “How to” on the Wiki for adding new pages.
I will try get it done this weekend.
Cheers.
I just added my own UMG tutorial, on the BP side of things funnily enough!
you can go to my tutorial and click on it to edit it to see how I put it together!
Most important thing is to add this tag at the bottom of your tutorial:
[Category:Code]]
or
[Category:Tutorials]]
I will thank you :).
Hello again i have added this tutorial to the wiki.
.
Oooh very nice! This will be very helpful for people!
I’ve linked to your tutorial in my UMG related tutorials section!
Yay for !
Hi,
I’m trying to extend UUserWidget, but can’t cast the widget to my class.
I get
This is what I have:
UCLASS()
class UMyUserWidget : public UUserWidget
{
GENERATED_UCLASS_BODY()
}
Error shows up with:
BackButton = CreateWidget<UMyUserWidget>(PlayerController, BackButtonClass);
or
BackButton = Cast<UMyUserWidget>(CreateWidget<UUserWidget>(PlayerController, BackButtonClass));
BackButtonClass is of type TSubclassOf<UUserWidget>
Any idea how I can go around this?
Thanks.
Any error messages ?
Ok, for some unknown reason the cast is now working lol
What’s still not working is getting the BackButtonClass from the widget specified on the defaults.
DGMenuHUD.h
UCLASS()
class ADGMenuHUD : public AHUD
{
GENERATED_UCLASS_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HUD)
TSubclassOf<UUserWidget> BackButtonClass; // <-- Also tried with TSubclassOf<UDGMenuUserWidget>
private:
UPROPERTY()
class UDGMenuUserWidget* BackButton;
}
DGMenuHUD.cpp
#include "DGMenuUserWidget.h"
#include "DGMenuHUD.h"
ADGMenuHUD::ADGMenuHUD(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP){}
void ADGMenuHUD::BeginPlay()
{
Super::BeginPlay();
UUserWidget* UserWidget = CreateWidget<UUserWidget>(this->PlayerController, BackButtonClass); // <-- BackButtonClass is NULL
// so UserWidget is also NULL
BackButton = Cast<UDGMenuUserWidget>(UserWidget);
}
Is this wrong:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HUD)
TSubclassOf<UUserWidget> BackButtonClass;
Or is there another way to specify the widget/class through the editor?
Ok… never mind. I was setting up the blueprint, but using the C++ class in the game mode… gawwh… facepalm
Thank you! This was very helpful!
Hi,
I followed the described Steps and also checked the wiki, but this seems to not work anymore in 4.6.1
Is this already known? or (may be) it’s just a Mac thing…
In Addition, also It did not help, but I suppose it is important to explicitly set the UCLASS Specifiers to get the wanted behavior also in the subclass:
UCLASS(Abstract, editinlinenew, BlueprintType, Blueprintable, meta=( Category=“IngameUI” ))
class UIngameUIWidget : public UUserWidget, public IIngameUICanvasChild
The problem is: Also my code compiles fine, I cannot select my class to reparent a newly created UMG Widget.
Any advises on this?
thanks
Hmm i will be going over the Wiki entry and update it over the weekend.
I see some have had some small issues before and its become a bit simpler with extending user widget as well.
Give me the weekend and i have a updated version for you.
Not sure way you can`t set it to parent,
but if the class is Abstract dont you need to use a derived class for BP/ Widget Parent class?
Killer tutorial, wouldn’t have guessed what was keeping me from extending UUserWidget in a million years. Thanks man!
Glad it was helpfull, this has actualy got a lot simpler since i did it last.
So i made a new Wiki Entry for it, as i did not want to remove the old tutorial all together.
New Wiki: https://wiki.unrealengine.com/Extend_UserWidget_for_UMG_Widgets
Also includes a Project Download if anyone wants to check out the finished tutorial.
I have updated the OP and added a link to the new tutorial on the wiki as well.
I’d say you saved my day, but it’s more like you saved my month. Thanks a lot for taking the time to write this and the tutorial in the wiki! Now I know blueprint classes can be reparented, which is useful in other cases too.
I realize this topic is old, but how would I go about writing a function that’d pass UMG elements (which I understand are just Slate elements?) into a C++ Function/Event for processing there before updating back to the Blueprint?
Assuming I understand this correctly, I’m trying to make a function that takes a SGridPanel as input (which is a UniformGridPanel in UMG?) so I can refresh it’s slots before pushing it back out to the blueprint.
perfect guide thanks guys!