Download

"FObjectInitializer::Get() can only be inside UObject-derived class constuctor" error in plugin

Hi, Unreal gurus,

I’m implementing a InputDevice plugin in order to add some extra event to virtual stick.
I start with this guide and change as few as possible to make it compatible with recent UE4 version. It can be built fine.
(You can check my source in attachment. I didn’t do any complex operation, just add some LOG, that’s all.)

But unfortunately, when I enable this plugin in a code project.
The UE4Editor crash with the following message:


[2017.06.19-09.17.51:658]  0]LogTemp:Warning: Created new input device!
Fatal error: [File:/home/sbbg/Shared/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 3208] 
FObjectInitializer::Get() can only be used inside of UObject-derived class constructor.
[2017.06.19-09.17.51:660]  0]LogLinux:Error: appError called: Assertion failed: Assertion failed:  [File:/home/sbbg/Shared/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 3208] 
FObjectInitializer::Get() can only be used inside of UObject-derived class constructor.

Signal 11 caught.


I wonder why does this fail so miserably.
I also check some plugin on GitHub like: GitHub - getsetgames/Swipe: A plugin for Unreal Engine 4 that exposes swipes on mobile devices as events in blueprint. and GitHub - getnamo/CIMPlugin: Custom Input Mapping Plugin for the Unreal Engine 4.
Found that: they didn’t even implement IInputDeviceModule at all.

Does it have anything to do with this crash?
Is the input plugin guide outdated now?

The message is fairly straightforward, it just means you have a class that isn’t deriving from UObject and you’re trying to use the FObjectInitializer in the constructor - which can’t be done.