in UE 4.13.2, I had the same issue, and sloved by 4 steps:
1.Enable “Project Setting-Project-Packaging-Native Blueprint Assets”
- Add #Include to the tail of your “ProjectName”.h
#include “Runtime/UMG/Public/UMG.h”
#include “Runtime/UMG/Public/UMGStyle.h”
#include “Runtime/UMG/Public/Slate/SObjectWidget.h”
#include “Runtime/UMG/Public/IUMGModule.h”
#include “Runtime/UMG/Public/Blueprint/UserWidget.h”
3.Add AddRange to your “ProjectName”.Build.h
PublicDependencyModuleNames.AddRange(new string[] { “Core”, “CoreUObject”, “Engine”, “InputCore”, “UMG” });
PrivateDependencyModuleNames.AddRange(new string[] { “Slate”, “SlateCore” });
4:use LoadClass instead of LoadObject
UIS_UIBase :my UI C++ base class name , change to yours.
UIS_UIBase* AIS_UIManager::LoadWidget(FString Name)
{
UClass * UIClass = LoadClass<UIS_UIBase>(NULL, (Path + Name + “.” + Name + “_C”));
if (UIClass)
{
UIS_UIBase UI = CreateWidget<UIS_UIBase>(GetWorld()->GetFirstPlayerController(), UIClass);
return UI;
}
UE_LOG(LogClass, Error, TEXT(“No such UIBlueprint! : %s%s”), *Path, *Name);
return nullptr;
}