As part of the Python and Editor Scripting Tools, it is possible to programmatically set variables in actor instances of the current level just like when using the Details Panel in the Level Editor. This is done using function set_editor_property() in Python and the BlueprintCallable UKismetSystemLibrary::SetEditorProperty() in Editor Utility Widgets/Blueprints. However, when the current level has "External Actors" enabled, these functions incorrectly fail to set variables of type "Actor Object Reference". The output log displays an error stating that the variable cannot be edited on templates, even though the set was called on an actor instance.
The problem does not happen if "External Actors" is disabled, or when using the direct setters of the variables (when those setters are available) instead of SetEditorProperty().
The faulty behavior can be explained as follows:
1) Variables of type "Actor Object Reference" are automatically marked as CPF_DisableEditOnTemplate, which is correct, since blueprints can be instantiated on any level and there is no guarantee that a default reference would be valid.
2) When external actors are enabled, AActor::IsAsset() returns true, which also makes sense
3) Both SetEditorProperty() functions above perform the check PropertyAccessUtil::IsObjectTemplate() on the owner of the variable being changed. This returns true when AActor::IsAsset() is true (which does not seem to be correct in this case). As a result, the setter functions disallow the change and the call fails.
world = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_editor_world()
actor_class = unreal.EditorAssetLibrary.load_blueprint_class("/Game/BPActor")
other_class = unreal.EditorAssetLibrary.load_blueprint_class("/Game/BPOther")
actor_instance = unreal.GameplayStatics.get_actor_of_class(world, actor_class)
other_instance = unreal.GameplayStatics.get_actor_of_class(world, other_class)
actor_instance.set_editor_property("ActorRef", other_instance)
--> LogPython: Error: Exception: Actor: Property 'ActorRef' for attribute 'ActorRef' on 'BPActor_C' cannot be edited on templates
--> LogScript: Warning: Script Msg: Property 'ActorRef' on '/Temp/Map_Test.Map_Test:PersistentLevel.BPActor_C_UAID_CC96E51C7175DFF601_1144202185' (BPActor_C) cannot be edited on templates
--> Note: If the node SetEditorProperty() is replaced by a direct variable setter, the set succeeds without any problem
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-215347 in the post.
0 |
Component | UE - World Creation - Worldbuilding Tools |
---|---|
Affects Versions | 5.3.2 |
Target Fix | 5.5 |
Fix Commit | 33891702 |
---|
Created | May 19, 2024 |
---|---|
Resolved | May 24, 2024 |
Updated | Jun 5, 2024 |