SlotAsCanvasSlot returns NULL?


Im using this

void UGalileaDialogueW::Ay()
    UGalileaDialogueCharW* Ref = CreateWidget<UGalileaDialogueCharW>(GetOwningPlayer(), TextTemplate);
    UCanvasPanelSlot* Panel = UWidgetLayoutLibrary::SlotAsCanvasSlot(Ref);
    Panel->SetPosition(FVector2D(0, 0)); // CRASH HERE!

So i can change the position of a widget im creating at runtime, Which is why im using SlotAsCanvasSlot so i can cast it to a CanvasPanelSlot and change its position, however the function seems to always be returning NULL since as soon i try to access its result the game crashes

I Tried the exact same function & order on a blueprint and for some reason it worked?, Im just wondering why it only crashes when i try to handle it trough C++

1 Like

Hey did you find a solution for this? I am having the same problem. Turns out the Slot is null after CreateWidget.

I have the same problem.

I also have this problem.

6 years later and I have the same problem. Guess we’ll never find out.