‘NiagaraSystemConversionContext’ はアトリビュート’get_emitter’を持っていない。
ドキュメントには
https://docs.unrealengine.com/5.3/en-US/PythonAPI/class/NiagaraEmitterConversionContext.html#unreal.NiagaraEmitterConversionContext
get_emitter() のメソッドを持っているとされているが
持っていない。
import unreal
def get_and_set_spawn_time_in_niagara_systems(folder_path, new_spawn_time):
# アセットレジストリにアクセス
asset_registry = unreal.AssetRegistryHelpers.get_asset_registry()
# 指定フォルダ内の全アセットを取得
asset_data_list = asset_registry.get_assets_by_path(folder_path, recursive=True)
# 各アセットをチェック
for asset_data in asset_data_list:
print("asset_data= "+str(asset_data))
print("asset_data.asset_class_path= "+str(asset_data.asset_class_path))
print("asset_data.asset_class_path.asset_name= "+str(asset_data.asset_class_path.asset_name))
# アセットがNiagaraSystemかどうかを確認
#if asset_data.asset_class == 'NiagaraSystem':
if asset_data.asset_class_path.asset_name == 'NiagaraSystem':
# アセットをロード
niagara_system = unreal.EditorAssetLibrary.load_asset(asset_data.package_name)
print("niagara_system= "+str(niagara_system))
import inspect
obj=niagara_system
#print type(obj)
#for x in inspect.getmembers(obj, inspect.ismethod):
# print(x[0])
#for x in dir(obj):
# print( str(x)+':'+str( eval("obj."+x)))
#NiagaraSystemConversionContext = niagara_system.get_editor_property("create_system_conversion_context")
#print("NiagaraSystemConversionContext= "+str(NiagaraSystemConversionContext))
# NiagaraSystemConversionContextを取得
NiagaraSystemConversionContext=niagara_system.create_system_conversion_context()
print("NiagaraSystemConversionContext= "+str(NiagaraSystemConversionContext))
# エミッタを取得
emitters = NiagaraSystemConversionContext.get_emitter()
print("emitters= "+str(emitters))
"""
for emitter in emitters:
# 各エミッタのスクリプトを取得
emitter_handle = niagara_system.get_emitter_handle(emitter)
emitter_graph = emitter_handle.get_source_graph()
# SpawnBurstInstantaneous モジュールを探す
for module in emitter_graph.get_nodes_of_class(unreal.NiagaraNodeFunctionCall):
if module.get_full_name().endswith("SpawnBurstInstantaneous"):
# パラメータの変更
parameters = module.get_parameter_map()
for param in parameters:
if param.get_name() == 'SpawnTime':
# 現在のSpawnTimeを取得
current_spawn_time = param.get_value()
print(f"Current SpawnTime: {current_spawn_time}")
# 新しいSpawnTimeを設定
param.set_value(new_spawn_time)
print(f"New SpawnTime set to: {new_spawn_time}")
# 変更を保存
unreal.EditorAssetLibrary.save_asset(asset_data.object_path)
"""
# 実行
editor_util = unreal.EditorUtilityLibrary()
EnvName_Str=editor_util.get_current_content_browser_path()
print("EnvName_Str= "+str(EnvName_Str))
folder_path = '/Game/MyNiagaraSystems' # 対象フォルダを指定
folder_path = EnvName_Str # 対象フォルダを指定
new_spawn_time = 1.0 # 新しいSpawnTimeの値
get_and_set_spawn_time_in_niagara_systems(folder_path, new_spawn_time)
結果
LogPython: niagara_system= <Object '/Game/Developers/notsuka/EditorUtilityWidget/EUW_NiagaraSystem_SpawnBurstInstantaneous/TestData/confist_NiagaraSystem.confist_NiagaraSystem' (0x00000A8F397D0E00) Class 'NiagaraSystem'>
LogPython: NiagaraSystemConversionContext= <Object '/Engine/Transient.NiagaraSystemConversionContext_3' (0x00000A8F4487F8C0) Class 'NiagaraSystemConversionContext'>
LogPython: Error: Traceback (most recent call last):
LogPython: Error: File "F:/SandBox/UE532NiagaraSysGet_Emmitter/UE532NiagaraSys/Tools/PythonTools/dir_niagara_emitter_module_spawn/dir_niagara_emitter_module_spawn_V2.py", line 70, in <module>
LogPython: Error: get_and_set_spawn_time_in_niagara_systems(folder_path, new_spawn_time)
LogPython: Error: File "F:/SandBox/UE532NiagaraSysGet_Emmitter/UE532NiagaraSys/Tools/PythonTools/dir_niagara_emitter_module_spawn/dir_niagara_emitter_module_spawn_V2.py", line 37, in get_and_set_spawn_time_in_niagara_systems
LogPython: Error: emitters = NiagaraSystemConversionContext.get_emitter()
LogPython: Error: AttributeError: 'NiagaraSystemConversionContext' object has no attribute 'get_emitter'