UObject
#include "UObject/Object.h"
Access: public
Specifiers: UCLASS
Description
The base class of all Unreal Engine objects. UObject provides the foundation for the reflection system, garbage collection, serialization, and networking replication. Every UObject-derived instance is tracked by the garbage collector and must not be deleted manually with `delete`.
Signature
class UObject : public UObjectBaseUtility Caveats & Gotchas
- • Never delete a UObject manually. The garbage collector manages lifetime. Use `MarkAsGarbage()` to signal an object for collection.
- • UObject instances cannot be created on the stack. Always use `NewObject<T>()` or `CreateDefaultSubobject<T>()`.
- • UObject is not thread-safe by default. Access from game thread only unless using appropriate synchronization.
- • Do not use raw pointers to UObjects across frames without ensuring the object is still valid (use `IsValid()`).
Example
Creating a UObject subclass C++
UCLASS()
class MYGAME_API UMyObject : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString MyData;
void DoSomething();
};
// Creating an instance
UMyObject* Obj = NewObject<UMyObject>(this);
Obj->MyData = TEXT("Hello"); Functions (11)
Utility 10 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UObject::GetName |
| public | function | UObject::GetClass |
| public | function | UClass::GetDefaultObject |
| public | function | UObject::GetOuter |
| public | function | UObject::GetTypedOuter |
| public | function | UObject::GetWorld |
| public | function | UObject::IsA |
| public | function | UObject::IsValid |
| public | function | UObject::MarkAsGarbage |
| public | function | UObject::PostInitProperties |
Math 1 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UObject::Implements |
See Also
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.5 | stable | — |
| 5.4 | stable | — |
Feedback
Was this helpful?