I can see that in your line a few things:
FStringClassReference MyWidgetClassRef(TEXT("/Game/c++calsses/UI/PreLevelSelect.PreLevelSelect"))
- Based on the example provided in the first link there string reference ends with a _C, and yours doesn’t; maybe that is causing an issue here. Your string reference should read “/Game/c++calsses/UI/PreLevelSelect.PreLevelSelect_C”
- There is the misspelling of the word ‘classes’ in your string reference, so just be sure that the spelling matches the directory.
What is also referenced in that link is that you should try to use a UPROPERTY of TSubclassOf for a reference to your UI object. Here is an example from my personal project of this property that I have in my player controller .h:
// Reference UMG Asset in the Editor
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Hero|UI|Main")
TSubclassOf<class UHeroCharacterUIMain> HeroMainUI;
Then, I have this logic in my player controller cpp:
if (HeroMainUI)
{
HeroMainWidget = CreateWidget<class UHeroCharacterUIMain>(GetGameInstance(), HeroMainUI);
if (HeroMainWidget)
{
HeroMainWidget->AddToViewport();
}
}
I hope this will help and good luck