Thought I’d elaborate further for anyone googling:
I’m trying to write a python script that modifies the members of a user-created struct.
It seems you cannot accomplish this with blueprint-created structs. Attempting to do so always results in “Failed to find property” error.
However, doing this with C++ is trivial. For instance, say I created the following struct in C++:
USTRUCT(BlueprintType)
struct FItemTest
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float FloatTest;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString StringTest;
};
I add this struct to a blueprint class. Now, to modify the default value of the struct, I run the following python script:
import unreal
bp_object = unreal.EditorAssetLibrary.load_blueprint_class('/Game/ProjectName/Characters/NPC_Test')
bp_default_object = unreal.get_default_object(bp_object)
bp_default_object.get_editor_property("ItemTest").set_editor_property("FloatTest", 1)
This successfully modifies the “FloatTest” struct member and sets the value to 1.