GENERATED_BODY() causing function declaration and member inaccessibility errors

First of all: you can find the definition of NewObject in UObjectGloabs.h:1221 this is its full signature:

    T* NewObject(UObject* Outer, UClass* Class, FName Name = NAME_None, EObjectFlags Flags = RF_NoFlags, UObject* Template = nullptr, bool bCopyTransientsFromClassDefaults = false, FObjectInstancingGraph* InInstanceGraph = nullptr)

So the signature works as follows:

  • Outer: the outer object can be any object. It is used to determine the lifecycle and how it will be saved, to my knowledge.
    (If you created a component you would probably use the actor that the component should stick to as the outer)
  • Class: this is used to spawn blueprint classes. If you just use a c++ class, you can just use YourClass::StaticClass() as this argument.
  • Name: is simply the name it will have. This will be the name you will see when inspecting it in the world outliner for example. you don’t have to name it
  • Flags: The definition reveals that this is some very low level stuff. I never used this.
  • Template: This is the object that you want to copy construct from
  • bCopyTransientsFromClassDefaults: No idea
  • InInstanceGraph: No Idea

The baseline is: all the “No Ideas” have default values, so just use those default values.