Ok, I got it hours later, it seems that the default value winw, so one needs to override the default value.
# need to be set before spawning, otherwise
# the value will be reset to the default in
# the construction phase
cdo = unreal.get_default_object(bp_class)
cdo.set_editor_property("Prompt", "Hello Word Again")
I assume using data object that encapsulate the data will not lead to the same behaviour.
Full Script:
import unreal
import json
import os
import random
# Load JSON entries
file_path = os.path.join(os.path.dirname(__file__), "test_content", "content.json")
with open(file_path, "r", encoding="utf-8") as f:
entries = json.load(f)
# Path to the source Blueprint
source_bp_path = "/Game/ThirdPerson/AI/Enemy_Character.Enemy_Character"
# Destination for generated assets
destination_folder = "/Game/ThirdPerson/AI/Generated_Characters"
# Ensure the folder exists
if not unreal.EditorAssetLibrary.does_directory_exist(destination_folder):
unreal.EditorAssetLibrary.make_directory(destination_folder)
# Get world and nav system, used to spawn at location down the line
world = unreal.EditorLevelLibrary.get_editor_world()
nav_sys = unreal.NavigationSystemV1.get_navigation_system(world)
for entry in entries:
asset_name = f"{entry['id']}_BP"
asset_path = f"{destination_folder}/{asset_name}"
asset = unreal.EditorAssetLibrary.load_asset(asset_path)
if not asset:
asset = unreal.EditorAssetLibrary.duplicate_asset(source_bp_path, asset_path)
# Load class from duplicated Blueprint
generated_class_path = f"{asset_path}.{asset_name}"
bp_class = unreal.EditorAssetLibrary.load_blueprint_class(generated_class_path)
# need to be set before spawning, otherwise
# the value will be reset to the default in
# the construction phase
cdo = unreal.get_default_object(bp_class)
cdo.set_editor_property("Prompt", "Hello Word Again")
# Close to the players launch area for now
origin = unreal.Vector(900, 1110, 92)
radius = 10000
location = nav_sys.get_random_reachable_point_in_radius(world, origin, radius)
if not location:
print(f"No valid navigable location found for {entry['id']}")
quit() #fail early
actor = unreal.EditorLevelLibrary.spawn_actor_from_class(bp_class, location, rotation = unreal.Rotator(0, random.uniform(0, 360), 0) )
unreal.EditorAssetLibrary.save_loaded_asset(asset)