Download

Error Trying to use MoveWindowTo Function

Hello,
I’m trying to expose the MoveWindowTo function to blueprints, but I’m running into a linker error:


Error    LNK2019    unresolved external symbol "__declspec(dllimport) public: void __cdecl SWindow::MoveWindowTo(struct FVector2D)" (__imp_?MoveWindowTo@SWindow@@QEAAXUFVector2D@@@Z) referenced in function "public: static void __cdecl UCustomBlueprints_Options::MoveWindowTo(float,float)" (?MoveWindowTo@UCustomBlueprints_Options@@SAXMM@Z) 

If I comment out the line with window->MoveWindowTo(…) then the code compiles fine. Using UE 4.23.1 and Visual Studio Community 2017
I looked at the API documentation for SWindow and included “Widgets/SWindow.h” but it still wouldn’t compile. Is there a different header I need to include or is there a glaring mistake I’m making that I’m oblivious to? Thanks in advance!

Header File:


#pragma once
#include "Engine.h"
#include "Widgets/SWindow.h"
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CustomBlueprints_Options.generated.h"

/**
 *
 */
UCLASS()
class MYGAME_API UCustomBlueprints_Options : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

public:
    UFUNCTION(BlueprintCallable, Category = "Settings")
        static void MoveWindowTo(float windowXPosition, float windowYPosition);

};

cpp File:


#include "CustomBlueprints_Options.h"
void UCustomBlueprints_Options::MoveWindowTo(float windowXPosition, float windowYPosition) {
    if (GEngine && GEngine->GameViewport) {
        TSharedPtr<SWindow> window = GEngine->GameViewport->GetWindow();
        window->MoveWindowTo(FVector2D(windowXPosition, windowYPosition));        

    }
}

I was able to figure out what was wrong. I was initially confused because SWindow.h was already declared in external dependencies. But I had to uncomment a line in MyGame.Build.cs:


// Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });

After uncommenting that, compiles fine :confused: