First of all insted of UWatcher*
use WeakObjectPtr<UWatcher>
or else you risking invalid pointer, also read here how to keep this object alive and prevent it from garbage collection:
As main issue, you eather need to get module class object form module manager:
Or create singleton in your module class so you can direcly refrence it, you cna look up in other modules in engine to see how it works, here example of HTTP:
HTTP_API static FHttpModule& Get();
/** singleton for the module while loaded and available */
static FHttpModule* Singleton;
and in CPP
FHttpModule& FHttpModule::Get()
{
if (Singleton == NULL)
{
check(IsInGameThread());
FModuleManager::LoadModuleChecked<FHttpModule>("HTTP");
}
check(Singleton != NULL);
return *Singleton;
}
I know you plan to do so with UObject, but i’m not sure if that is safe thing to do, so i recomand you to it with module class as most module classes in engine do.