Hi! I wanted to make an automated tool that would programmatically modify the value of a Component in many blueprints, my approach is to use Reflection in C++ to set a parameter to the SkeletalMeshComponent in an Actor blueprint, first I want to read the SkeletalMeshComponent. How should I start?
Here is my solution, but sadly I can not read SKptr because it is a null ptr
UBlueprint* BPPtr = Cast<UBlueprint>(InObject);
UObject* BPCDO = BPPtr->GeneratedClass->GetDefaultObject();//CDO
TSubclassOf<AActor> ActorClassCast = BPCDO->GetClass();
for (TFieldIterator<UObjectProperty> ProIt(ActorClassCast); ProIt; ++ProIt)
{
UObjectProperty* Pro = *ProIt;
if (Pro->GetName() == PropertyNameTwo)
{
void* Addr = Pro->ContainerPtrToValuePtr<void>(ActorClassCast->GetDefaultObject());
UObject* SKptr = Pro->GetPropertyValue(Addr);
if (SKptr)
{
//do sth
}
}
UE_LOG(LogTemp, Warning, TEXT("Property Class is %s"), *Pro->PropertyClass->GetName());
}
In case someone else is looking for a solution, I’m trying to get a Component variable that inherits from the blueprint base class through reflection.
So I can only get the basic information about the Class (name, etc.) and not the Component variables.
My solution: I put my need to modify the blueprint generated to the Level, through the blueprint script modify ActorComponent parameters, then through SSCSEditor: : OnApplyChangesToBlueprint () function is ActorComponent modification applied to its blueprint.