Exception with delegate in FSceneViewport

I want to know if the window is resized so I want to bind a function to the OnSceneViewportResizeDel in FSceneViewport.

So I did this:

FSceneViewport* pSceneViewport = GetGameViewport();
FOnSceneViewportResize InOnSceneViewportResize;
InOnSceneViewportResize.BindUObject(this, &UMyGameViewportClient::OnResize);
InOnSceneViewportResize.Execute(FVector2D());
pSceneViewport->SetOnSceneViewportResizeDel(InOnSceneViewportResize);

As soon as I hit play I get following exception:

TBaseDelegate_OneParam::operator=() 0xd948ca61 + 11 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:629] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-Engine.dll]
FSceneViewport::SetOnSceneViewportResizeDel() 0xd94cf772 + 12 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\runtime\engine\public\slate\sceneviewport.h:161] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-Engine.dll]
UMyGameViewportClient::Init() 0xd2cb266f + 69 bytes [File=e:\unreal projects\nstopdowncameratask\source\nstopdowncameratask\private\mygameviewportclient.cpp:25] [in E:\Unreal Projects\NSTopDownCameraTask\Binaries\Win64\UE4Editor-NSTopDownCameraTask.dll]
UEditorEngine::CreatePlayInEditorWorld() 0xd7d86bae + 16 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\editor\unrealed\private\playlevel.cpp:2494] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
UEditorEngine::PlayInEditor() 0xd7da63b5 + 0 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\editor\unrealed\private\playlevel.cpp:1997] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
UEditorEngine::StartQueuedPlayMapRequest() 0xd7db60e9 + 0 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\editor\unrealed\private\playlevel.cpp:836] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
UEditorEngine::Tick() 0xd7ba28b8 + 13 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\editor\unrealed\private\editor.cpp:1096] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
UUnrealEdEngine::Tick() 0xd7f7e956 + 0 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\editor\unrealed\private\unrealedengine.cpp:252] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
FEngineLoop::Tick() 0x40007092 + 0 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\runtime\launch\private\launchengineloop.cpp:2084] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor.exe]
GuardedMain() 0x3fffc8cc + 0 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\runtime\launch\private\launch.cpp:133] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor.exe]
GuardedMainWrapper() 0x3fffc93a + 5 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\runtime\launch\private\windows\launchwindows.cpp:125] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor.exe]
WinMain() 0x40008499 + 17 bytes [File=e:\unreal engine\unrealengine-4.3\engine\source\runtime\launch\private\windows\launchwindows.cpp:207] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor.exe]
__tmainCRTStartup() 0x40009339 + 21 bytes [File=f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618] [in E:\Unreal Engine\UnrealEngine-4.3\Engine\Binaries\Win64\UE4Editor.exe]
Address = 0x76d459ed (filename not found) [in C:\Windows\system32\kernel32.dll]
Address = 0x76e7c541 (filename not found) [in C:\Windows\SYSTEM32\ntdll.dll]
Address = 0x76e7c541 (filename not found) [in C:\Windows\SYSTEM32\ntdll.dll]

I don’t know what I am doing wrong. Does someone has an idea how to fix that or how to catch the window resizing without changing the unreal engine code.

Hey.
What i did was get viewport like this

if (GetWorld() && GetWorld()->GetGameViewport())

{

UGameViewportClient* VPClient = GetWorld()->GetGameViewport();

FSceneViewport* VP = VPClient->GetGameViewport();



FOnSceneViewportResize VPResize;

VPResize.BindUObject(this, &ATestPawn::ViewPortResize);

VP->SetOnSceneViewportResizeDel(VPResize);

}

and The function ViewportResize is:

void ATestPawn::ViewPortResize(FVector2D vector)

{

ScreenSizeX = vector.X;

ScreenSizeY = vector.Y;

}

i use this for getting windows size when it changes.


1 Like

I’ve never done this but I may need something similar in future so I thought I’d have a quick look.

Best info I can find is here: ExtraCamWindow/ExtraCamWindowActor.cpp at master · chaosgrid/ExtraCamWindow · GitHub

In this example a lamba function is created rather than binding which might be suitable for you but if not, perhaps the surrounding code will help resolve the issue (note that the code looks like it’s creating a new viewport rather than binding to an existing one)

I’m also assuming that your OnResize method has a FVector2D param for the ‘new size’.