UObject::GetClass
#include "UObject/UObjectBase.h"
Access: public
Specifiers: inlineconst
Description
Returns the UClass that describes this object's type, fields, and metadata. Always valid for any live UObject.
Signature
FORCEINLINE UClass* GetClass() const Return Type
UClass* Caveats & Gotchas
- • Never returns null on a valid, non-garbage-collected UObject. If calling on a potentially stale pointer, validate with IsValid() first.
- • For cast checks, prefer IsA<T>() or Cast<T>() rather than comparing GetClass() == T::StaticClass() — the latter misses derived classes.
Example
Log the class name C++
if (IsValid(Obj))
{
UE_LOG(LogTemp, Log, TEXT("Class: %s"), *Obj->GetClass()->GetName());
} See Also
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?