Getting Actor of FProperty instance

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.

This actually seems to work

	TArray<UObject*> OuterObjects;
	Handle->GetOuterObjects(OuterObjects);

	for (int i = 0; i < OuterObjects.Num(); ++i)
	{
		TheComponent = Cast<UActorComponent>(OuterObjects[i]);
		TheActor = Cast<AActor>(TheComponent->GetOwner());
		TheActorName = TheActor->GetName();		
	}

But does seem smelly

1 Like