Hi Austin,
The functions in WidgetComponent aren’t exported in a way that other modules can communicate with them.
If you were to look at WidgetComponent.h, somewhere in the UCLASS metadata it will read MinimalAPI, which doesn’t export the symbols, hence “unresolved external symbol” when you’re trying to call GetUserWidgetObject();
By removing that MinimalAPI metadata and adding the module API prefix to the class declaration line in the header:
class UMG_API UWidgetComponent : public UPrimitiveComponent
You can export every function so that they can be accessed by other modules (such as your gameplay module).
This does involve making a change to the UE4 source code though, unless they decide to export the symbols by default in future.
In order to pull those headers in from your external module (UMG), open your Project.Build.cs file in your game module folder, and on the PublicDependancyModuleNames line, add the UMG module, which is from the UMG folder name. Here’s mine:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore", "HeadMountedDisplay" });
Then in the class you’re working in #include “WidgetComponent.h” and “UserWidget.h”, or an extended version of that class.
Also found this: “Functions and classes that need to be accessed outside of their module must be exposed via the *_API macros. Each item that is exposed comes with a compile-time cost, so be sure to only expose what is needed. If you only need access to a single function in a class, exposing just that function instead of the class can save a significant amount of time when compiling.”
https://docs.unrealengine.com/latest/INT/Programming/Basics/index.html
Also be aware that somewhere along the way, this process has borked my hot reload, and the unresolved external symbol error will keep happening unless you recompile with the editor closed and make sure it’s been closed for long enough that the editor is no longer in memory and hot reload doesn’t still fire.
I’ve gotten as far as getting my own traces to hit the widgetcomponent, pick up the widgets (such as a text box) using some maths, but I’m lacking the final part of the puzzle, which is setting the focus to the WidgetComponent and the textbox inside it so I can type on it. The default behaviour of widgetcomponent isn’t quite what I’m looking for, but this is a story for another answers post I think. Hope this helps!