ChatGPT kindly put this Python automation script together for me (and even drafted this post ). Could someone help me figure out the exact property name for the audio field inside my struct?
I’m working with a Blueprint Data Asset called BPDA_DialogueNPC
.
Inside it there’s a struct named DialogueData
(type E_DialogueNpcData
). In the editor I can see an audio slot, but when I try to set it from Python—using any of the obvious name AudioToPlay
—I get:
StructBase: Failed to find property '<NameTried>' on 'E_DialogueNpcData'
How can I discover (or expose) the real field name so my script can do:
dialogue_struct.set_editor_property("<CorrectFieldName>", my_sound)
UE 5.4 — Python Editor Script Plugin enabled.
import unreal
# ───────────────────────── CONFIGURATION ─────────────────────────
DA_CLASS = unreal.load_class(
None,
"/Game/CommonGameplaySystems/Dialogues/Data/BPDA_DialogueNPC.BPDA_DialogueNPC_C"
) # Blueprint class used for every new Data Asset
DEST_FOLDER = "/Game/Data/Audio" # Output folder for the generated assets
AUDIO_FOLDER = "/Game/-VFOS-/Assets/Wavs/Vixens/Irina/CommoPhases" # Folder that contains all the SoundWaves / SoundCues
OVERWRITE = False # Set to True to replace existing assets
# ─────────────────────────────────────────────────────────────────
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
editor_lib = unreal.EditorAssetLibrary
paths_lib = unreal.Paths
# ─────────────────── Gather all audio assets ─────────────────────
raw_paths = editor_lib.list_assets(
AUDIO_FOLDER,
recursive=True,
include_folder=False
)
# Only keep SoundWave / SoundCue (both derive from SoundBase)
audio_assets = [
unreal.load_asset(p)
for p in raw_paths
if isinstance(unreal.load_asset(p), unreal.SoundBase)
]
unreal.log(f"🎧 Found {len(audio_assets)} valid audio assets")
# ────────────────── Create one Data Asset per audio ──────────────
for sound in audio_assets:
base_name = paths_lib.get_base_filename(sound.get_path_name())
da_name = f"DA_{base_name}"
full_path = f"{DEST_FOLDER}/{da_name}"
# Skip if the asset already exists and we are not overwriting
if not OVERWRITE and editor_lib.does_asset_exist(full_path):
unreal.log_warning(f"❌ {da_name} already exists, skipped")
continue
# Create the new Data Asset
data_asset = asset_tools.create_asset(
da_name, # asset name
DEST_FOLDER, # destination folder
DA_CLASS, # class to use
unreal.DataAssetFactory() # factory for UDataAsset-based assets
)
# 1) Read the 'DialogueData' struct from the new asset
dialogue_struct = data_asset.get_editor_property("DialogueData")
# 2) Set the audio field (make sure the field name is correct)
dialogue_struct.set_editor_property("AudioToPlay", sound)
# 3) Write the modified struct back to the Data Asset
data_asset.set_editor_property("DialogueData", dialogue_struct)
# Save the asset to disk
editor_lib.save_loaded_asset(data_asset)
unreal.log(f"✅ {da_name} created with {sound.get_name()}")
unreal.log("🏁 All done")