Donspace
(Donspace)
June 11, 2020, 7:16am
1
In BallGenerator.cpp
I wrote:
But when I compiled it, it showed errors like:
C2338 The given OwningObject is not of a supported type for use with CreateWidget.
C2665 ��UUserWidget::CreateWidgetInstance��: 5 ��������û��һ������ת�����в�������
But in other tutorials their codes were just like what I wrote. What OwningObject should I use in CreateWidget?
2 Likes
k_Rave
(k_Rave)
June 16, 2020, 8:11am
2
Does BallGenerator derive from UWidget, UWidgetTree, APlayerController, UGameInstance or UWorld ?
As you can see in this screenshot from UserWidget.h, CreateWidget() checks if the owner derives one of these classes.
Also make sure to check the output log to see which class is used as the Owner in CreateWidget().
I thought my UWidget derived class was causing this error because I call CreateWidget() from this class, but the error actually came from my GameNetworkManager class which also called CreateWidget().
5 Likes
microjiao
(microjiao)
March 14, 2022, 9:40am
3
Thanks, Its help me~
I write it in GameMode file,so its error
You can put GetWorld()
instead of this
5 Likes
rxpel
(rxpel)
November 21, 2023, 12:12am
5
This worked for me, thank you very much