Thanks, I’ve managed to get the component templates using that method, and I can succesfully iterate over their properties.
I’m also able to write to the properties of the component template, and the value seems to be applied if I get it again in C++, however I can’t get it to update in the editor window (shown in the previous screenshot).
I’ve tried calling MarkPackageDirty() on both the Actor Blueprint and the Component Template, but that didn’t affect anything.
Am I setting the value incorrectly, or do I need to call something else to notify the editor of the change?
static void Test(UObject* Object)
{
UClass* Class = Object->GetClass();
if (UBlueprint* Blueprint = UBlueprint::GetBlueprintFromClass(Class); Blueprint)
{
for (const USCS_Node* It : Blueprint->SimpleConstructionScript->GetAllNodes())
{
for (TFieldIterator<FProperty> PropIt(It->ComponentTemplate->GetClass()); PropIt; ++PropIt)
{
FName PropName = PropIt->GetFName();
FString PropType = PropIt->GetClass()->GetName();
FProperty* Property = *PropIt;
if (PropName == "TESTBOOL")
{
if(void* ValPtr = Property->ContainerPtrToValuePtr<void>(It->ComponentTemplate); TargetValuePtr)
{
bool B;
Property->GetValue_InContainer(ValPtr, &B);
UE_LOG(LogTemp, Log, TEXT("Before setting: %s"), bIsTrue ? TEXT("True") : TEXT("False"));
B = true;
Property->SetValue_InContainer(ValPtr, &B);
UE_LOG(LogTemp, Log, TEXT("After setting: %s"), bIsTrue ? TEXT("True") : TEXT("False"));
}
}
}
}
}
}
(In the above example, any component with the boolean property named “TESTBOOL” should have its value set to ‘TRUE’. When you call it a second time, the value is still ‘TRUE’ before setting it, implying it’s being stored, but not updated in the editor or saved).