Is it possible to have my own constructor in a class derived from UObject?
If yes, how should I pass the parameters to the constructor while instancing it with NewObject() since new seems not to be supported anymore?
Is it possible to have my own constructor in a class derived from UObject?
If yes, how should I pass the parameters to the constructor while instancing it with NewObject() since new seems not to be supported anymore?
As far as I know this is not possible. The suggested workaround is to define your own Init function which you can call after instantiating the object.
As far as I know this is not possible. The suggested workaround is to define your own Init function which you can call after instantiating the object.
I think my good twin is posting answers as well.
In this case, is it even reasonable to derive every custom class from UObject? Should I rather use raw c++ classes when there is no need to interact with the UE4 engine?
Well, there’s nothing wrong with that - it just depends on whether or not you want to use any of the good stuff like reflection and garbage collection built into the Unreal framework.
hi~ SyMutex.
i think, i can give you a clue.
replace ‘GENERATED_BODY()’ to '‘GENERATED_UCLASS_BODY()’ in header file of your custom class.
good luck
This is wrong! After UE4.6 you should NOT use GENERATED_UCLASS_BODY()