UActorComponent::Rename
#include "Components/ActorComponent.h"
Access: public
Specifiers: virtualoverride
Description
Renames this component and/or moves it to a new outer, updating the owning actor's component lists accordingly. Returns true on success.
Caveats & Gotchas
- • Renaming a component that is already registered will trigger `PostRename`, which updates `OwnedComponents` on the actor. Calling Rename during gameplay on a registered component can cause subtle bugs if anything caches the component by name.
- • Renaming a component after it has been networked will invalidate its stable name, causing net GUID reassignment on the next replication pass. Avoid renaming replicated components after their initial registration.
Signature
ENGINE_API virtual bool Rename( const TCHAR* NewName=NULL, UObject* NewOuter=NULL, ERenameFlags Flags=REN_None ) override; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| NewName | const TCHAR* | The new name for the component, or NULL to auto-generate one. | NULL |
| NewOuter | UObject* | The new outer object, or NULL to keep the current outer. | NULL |
| Flags | ERenameFlags | Flags controlling rename behaviour (e.g. REN_Test, REN_ForceNoResetLoaders). | REN_None |
Return Type
bool Example
Rename a component at construction time C++
AMyActor::AMyActor()
{
UStaticMeshComponent* Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TempMesh"));
// Rename before registration is safe
Mesh->Rename(TEXT("PrimaryMesh"), this);
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?