RealDocs

AActor::GetRootSelectionParent

function Engine Since 4.20
#include "GameFramework/Actor.h"
Access: public Specifiers: virtualENGINE_APIconst

Description

Returns the topmost actor in the editor selection hierarchy, traversing up through GetSelectionParent() until the root is found.

Caveats & Gotchas

  • The engine's default implementation walks the parent chain by calling GetSelectionParent() repeatedly. If your override creates a cycle in the parent chain, this will loop infinitely — always ensure the chain terminates.
  • For flat hierarchies where every actor is its own root, this returns the actor itself (via nullptr from GetSelectionParent), not nullptr.
  • This is used by IsActorOrSelectionParentSelected() internally — consistency between these functions is required for correct editor selection state.

Signature

ENGINE_API virtual AActor* GetRootSelectionParent() const

Return Type

AActor*

Example

Find the top selection root for an actor C++
AActor* Root = MyActor->GetRootSelectionParent();
if (Root && Root != MyActor)
{
    UE_LOG(LogTemp, Log, TEXT("%s is a child of selection root %s"),
        *MyActor->GetName(), *Root->GetName());
}

Version History

Introduced in: 4.20

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.