bigriver
(bigriver)
July 11, 2023, 1:57pm
1
Hi, I accessed valiables in a blueprint asset attached an actor in development build.
Like this,
if (UBlueprint* Blueprint = Cast<UBlueprint>(GetOwner()->GetClass()->ClassGeneratedBy))
{
TArray<const UBlueprintGeneratedClass*> BlueprintClasses;
UBlueprintGeneratedClass::GetGeneratedClassesHierarchy(Blueprint->GeneratedClass, BlueprintClasses);
for (auto Class : BlueprintClasses)
{
if (Class->SimpleConstructionScript)
{
for (auto Node : Class->SimpleConstructionScript->GetAllNodes())
{
if (UCustomComponent* Comp = Cast<UCustomComponent>(Node->GetActualComponentTemplate((UBlueprintGeneratedClass*)(Class))))
{
}
}
}
}
}
But in release build I couldn’t access to ‘ClassGeneratedBy’.
Is there another way to read valiables without ‘ClassGeneratedBy’ in release build?
Thank you in advance for your help.
Hi bigriver,
If you have access to the package (often the owner) you can do a FindObject like:
UPackage* package=UPackageTools::LoadPackage(packageName);
if(package) {
UBlueprint* bp=FindObject<UBlueprint>(package,*assetName,true);
}
You are not actually using the Blueprint in your code, simply going back and forth, from Class to BP and back to Class. The generated class is the same class you get from GetClass().
Try this
TArray<const UBlueprintGeneratedClass*> BlueprintClasses;
UBlueprintGeneratedClass::GetGeneratedClassesHierarchy(GetOwner()->GetClass(), BlueprintClasses);
bigriver
(bigriver)
July 14, 2023, 12:50pm
4
It works. I misunderstood how to code that completely. Thank you!
system
(system)
Closed
August 13, 2023, 12:51pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.