the first step is to get a hold of the actor (line-trace/collision), UWorld->GetActorOfClass<MyClass>()
if there is only ever to be one of these components on the actor then you can do a
Actor->FindeComponentByClass<UMyCompontent>()
, which can be wrapped into an if statement
UMyComponent* GetActorComponent(AActor* inActor)
{
if( UMyComponent* component = inActor->FindComponentByClass<UMyComonent>())
{
return component;
}
return nullptr;
}
there is also a plural version of this function but you will have to maybe step through them to find the “correct one”
if you really want to go through with getting properties by string (I would strongly suggest not doing this as it can lead to runtime resolution issues) then you might want to look into the different versions of PostEditChangeProperty, and PostEditChangeChainProplerty, which can deal with explicit properties by string.
the issues you will run into with Properties by string, is that they are absolute, and where this looks to be intended to have Blueprint visibility sometimes strings behave differently between C++ and Blueprints (technically Blueprints hard force ANSI strings, while even with C++ FString these can be treated as C_Strings, but treating an ANSI string as a C_String or visa-versa can have parsing issues.
I would maybe suggest either exposing the given property to Blueprints (either make it public, or use UPROPERTY(meta=(AllowPrivateAccess=true))
, or getters for those properties if validation shall be done on Get().
for the function you provided Components they will derive from UActorComponent
, and should be passed as pointer.