Page 1 of 1

UNoesisInstance::GetCachedWidget causes linker error

Posted: 21 Mar 2024, 20:18
by KCoppinsIventis
Hi there,

I am trying to get the cached widget to set my input mode in C++:
auto InputMode = FInputModeUIOnly();
InputMode.SetWidgetToFocus(NoesisInstance->GetCachedWidget());
UserController->SetInputMode(InputMode);
However this causes the following linker error:
unresolved external symbol "__declspec(dllimport) public: class TSharedPtr<class SWidget,1> __cdecl UWidget::GetCachedWidget(void)const " (__imp_?GetCachedWidget@UWidget@@QEBA?AV?$TSharedPtr@VSWidget@@$00@@XZ) referenced in function "public: void __cdecl UMainViewModel::ToggleLocationSelector(void)" (?ToggleLocationSelector@UMainViewModel@@QEAAXXZ)
I have tried including the following headers in both my header and main file:
#include "NoesisRuntime.h"
#include "Widgets/SUserWidget.h"
#include "Blueprint/UserWidget.h"
#include "Widgets/SWidget.h"
#include "Components/Widget.h"
Which header am I missing or is there something else here entirely? Thanks for any help!

Re: UNoesisInstance::GetCachedWidget causes linker error

Posted: 22 Mar 2024, 10:19
by KCoppinsIventis
I have figured out my issue, nothing with NoesisGUI. I just had to include the UMG public dependency module in my module's build.cs:
PublicDependencyModuleNames.AddRange(new string[] {  "UMG" });

Re: UNoesisInstance::GetCachedWidget causes linker error

Posted: 26 Mar 2024, 17:56
by sfernandez
Thanks for sharing the solution, even if it wasn't a Noesis issue :)