Custom game viewport client in a standalone module

Hi all!

I’m trying to implement a custom game viewport client class and I need to put it inside a standalone module located in Engine/Source/Developer/MuModule. The game project refers to this module in cs file by PublicDependencyModuleNames list and sets the custom viewport class inside DefaultEngine.ini.

The problem is when the engine tries to load the class from MyModule during initialization phase (when GameViewportClient is actually created) it can’t locate it inside /Script/MyModule.CustomGameViewportClient - it’s simply missing inside MyModule hash.

I have a number of assumption here:

  1. The stanadlone module’s uclasses might be registered later then the engine is initialized and game viewport client is created.
  2. I made something wrong with the MyModule structure or configuration so it doesn’t register its uclasses at all. Is something special required here?
  3. MyModule isn’t propery plugged-in inside the game project. Do I need to register the module references in a special way in order to be able to acces its uclasses?
  4. Something else?

Which one is true?

Any help will be greatly appreciated.
Thanks!

.

Ok, guys, I’ve got it.

The problem was that the standalone module with custom game viewport client class inside wasn’t referenced directly by the game module. The game viewport class is loaded dynamically with LoadClass in UEngine and I didn’t have any other references to its module. Therefore it was silently optimized out by the VC linker and no static initialization of the module took place. As a result - no module’s classes registered and no game viewport client class loaded in the end.

Beware of the dynamic class loading! You may miss the module if nothing else refers to it. Epic seems to fix this for plugins in monolitic builds, but not for the case I described. Also consider usage of dynamic loading for decopled modules which you need in any case.

In my case I’ve just created another game viewport client sibling in the game project inherited from my custom game viewport and this way a necessary reference to its module was created and it stopped to drop out :slight_smile: