NewObject

Convenience template for constructing a gameplay object

Choose your operating system:

Windows

macOS

Linux

References

Module

CoreUObject

Header

/Engine/Source/Runtime/CoreUObject/Public/UObject/UObjectGlobals.h

Include

#include "UObject/UObjectGlobals.h"

Syntax

template<class T>
T * NewObject
(
    UObject * Outer,
    const UClass * Class,
    FName Name,
    EObjectFlags Flags,
    UObject * Template,
    bool bCopyTransientsFromClassDefaults,
    FObjectInstancingGraph * InInstanceGraph,
    UPackage * ExternalPackage
)

Remarks

Convenience template for constructing a gameplay object

Returns

a pointer of type T to a new object of the specified class

Parameters

Parameter

Description

Outer

the outer for the new object. If not specified, object will be created in the transient package.

Class

the class of object to construct

Name

the name for the new object. If not specified, the object will be given a transient name via MakeUniqueObjectName

Flags

the object flags to apply to the new object

Template

the object to use for initializing the new object. If not specified, the class's default object will be used

bCopyTransientsFromClassDefaults

if true, copy transient from the class defaults instead of the pass in archetype ptr (often these are the same)

InInstanceGraph

contains the mappings of instanced objects and components to their templates

ExternalPackage

Assign an external Package to the created object if non-null