I want to be able to access and modify the properties on the Components of an Actor Blueprint CDO.
I can modify properties on the Actor in the CDO perfectly well, but I can’t seem to access the components (specifically those added in Blueprint) as they don’t exist on the CDO. If I get a list of the Actor’s components they’re just not in the list.
Is there a way to modify component properties on a CDO?
(I believe CDO is the one I need to change, as opposed to the Archetype, though I can’t access them on Archetypes either).
Thanks, I tried putting that into a function which prints all of the component template path names, but I can’t get ‘FindSCSNode’ to return a valid pointer. I’ve tried a couple of variations on the format with no luck.
I took a look inside that function and saw that the ‘GetAllNodes()’ function returns an empty array, so I tried calling that directly to narrow down the problem.
The following code will always log ‘Found 0 nodes’:
void FESToolsModule::TestFunctionX()
{
if (GEditor)
{
USelection* SelectedActors = GEditor->GetSelectedActors();
for (FSelectionIterator It(*SelectedActors); It; ++It)
{
if (const AActor* SelectedActor = Cast<AActor>(*It); SelectedActor)
{
int Count = UBlueprint::GetBlueprintFromClass(SelectedActor->GetClass())->SimpleConstructionScript->GetAllNodes().Num();
UE_LOG(LogESTools, Log, TEXT("Found %i nodes"), Count);
}
}
}
}
Were your components added in blueprint or directly to actor at the level? Added at level - accessible in the default way, without the need to use SCS.
They were added in the Blueprint Editor window, saved and compiled.
To keep things simple, I’ve just created a new Actor Blueprint that inherits from Static Mesh Actor. The behaviour is the same, not finding any nodes.
I’m calling my function from a custom toolbar button whilst having an actor selected in the map editor window.
The ultimate goal would be to do something like modify the Intensity or Light Color properties on the Point Light component (below) using C++, assuming I have a pointer to an instance of this class.
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;
(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).