Getting Actor of FProperty instance

jojothebandit
Fri, 02 Jul 2021 15:55:06 +0000
C++

Hello,

If I have an cpp component I can easily get the actor “i am in” with GetOwner()

But if I’m in plugin code, and have an Insance of a FProperty from some actor, it doesn’t seem I can get the actor instance in any way.
I can catch the component name from the owner, but can’t make it become the actor. I need the actor name.
I have tried the following:

TSharedPtr<IPropertyHandle> Handle // is a property handle
FProperty* TheProperty = Handle->GetProperty() // Is a FProperty*


//Directly
AActor* TheActor = Cast<AActor>(TheProperty ->GetOwner()); // Doesnt cast, stays nullptr

AActor* TheActor = Cast<AActor>(Handle->GetProperty()->GetOwnerUObject()); // Doesnt cast, stays nullptr


//Through the component

TheComponent = Cast<UActorComponent>(Handle->GetProperty()->GetOwner<UActorComponent>()); // Doesnt cast, stays nullptr
TheActor = Cast<AActor>(TheComponent->GetOwner()); // Doesnt cast, stays nullptr

Is there any way to get the actor?
For some context(simplified), i have made a plugin that when you click a property something happens, so i need to save the name so I know which actor it happened on.

2 posts - 1 participant