Custom game viewport client in a standalone module
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:
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 :)
answered Aug 26 '16 at 09:09 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here