Hello Vitor,
Thank you for the solution you provided earlier. However, I decided to take a different approach to the issue.
Instead of following your method, I added the function to the
BzEditorFunctionLibrary
and call it from my utility Blueprint.
Here’s the function I implemented:
`UActorComponent* UBzEditorFunctionLibrary::GetBlueprintComponentTemplate(UBlueprint* Blueprint, FName ComponentVarName)
{
if (!Blueprint)
{
return nullptr;
}
UClass* TargetClass = Blueprint->GeneratedClass;
if (!TargetClass)
{
return nullptr;
}
UBlueprintGeneratedClass* RootBPClass = Cast(TargetClass);
UClass* SearchClass = TargetClass;
while (SearchClass && SearchClass != AActor::StaticClass())
{
UBlueprintGeneratedClass* BPClass = Cast(SearchClass);
if (BPClass && BPClass->SimpleConstructionScript)
{
const TArray<USCS_Node*>& Nodes = BPClass->SimpleConstructionScript->GetAllNodes();
for (USCS_Node* Node : Nodes)
{
if (!Node)
continue;
FName NodeVarName = Node->GetVariableName();
if (NodeVarName == ComponentVarName)
{
UActorComponent* TemplateComp = Node->GetActualComponentTemplate(RootBPClass);
return TemplateComp;
}
}
}
SearchClass = SearchClass->GetSuperClass();
}
return nullptr;
}`
This function takes two inputs: a UBlueprint and a component variable name. It searches for the component by name within the Blueprint and returns the corresponding template component. You can then cast the output to the appropriate component class and access its properties as needed.
Thank you again for your help—no further assistance is required at this point.
Best regards,
Levan Surmanidze