头文件引入
#include "Engine/GameEngine.h"
#include "EngineGlobals.h"
模块添加
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
.cpp
bool UBlueprintFunctionLibrary::SetWindow_Minimize()
{
UGameEngine* gameEngine = Cast<UGameEngine>(GEngine);
if (gameEngine)
{
TSharedPtr<SWindow> windowPtr = gameEngine->GameViewportWindow.Pin();
SWindow *window = windowPtr.Get();
if (window)
{
window->Minimize();
return true;
}
}
return false;
}
参考:https://blog.youkuaiyun.com/weixin_36412907/article/details/78914768