UE4_Python_自动化导入素材脚本_音频_图片_FBX

1 新建项目,开启插件
UE4_Python_自动化导入素材脚本_音频_图片_FBX_第1张图片
2 项目设置—>Python
UE4_Python_自动化导入素材脚本_音频_图片_FBX_第2张图片
3 资源加载脚本 AssetFunctions.py(目录跟上图的目录一致)

导入FBX

import unreal

asset_path =  "E:/fireAxe.FBX"
asset_path2 =  "E:/fireAxe2.FBX"

def ImportMyAssets():
    asset_task = buildImportTask(asset_path,'/Game/Object')
    asset2_task = buildImportTask(asset_path2, '/Game/Object')
    executeImportTasks([asset_task,asset2_task])


# https://api.unrealengine.com/INT/PythonAPI/class/AssetToolsHelpers.html
def buildImportTask(filename,destination_path):
    task = unreal.AssetImportTask()
    task.set_editor_property('automated',True)
    task.set_editor_property('destination_name', '')
    task.set_editor_property('destination_path', destination_path)
    task.set_editor_property('filename',filename)
    task.set_editor_property('replace_existing',False)
    task.set_editor_property('save',False)
    return task

# https://api.unrealengine.com/INT/PythonAPI/class/AssetTools.html
def executeImportTasks(tasks):
    unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)


UE4_Python_自动化导入素材脚本_音频_图片_FBX_第3张图片

4 依次执行

 import AssetFunctions as AF
 AF.ImportMyAssets()

5 然后,素材自动导入到项目中
UE4_Python_自动化导入素材脚本_音频_图片_FBX_第4张图片

导入音频和图片

import unreal

texture_tga = "E:/Test/Img.TGA"
sound_wav = "E:/Test/bgm.WAV"


def importMyAssets():
    sound_task = buildImportTask(sound_wav, '/Game/Sounds')
    texture_task = buildImportTask(texture_tga, '/Game/Textures')
    executeImportTasks([sound_task, texture_task])


def buildImportTask(filename, destination_path):
    task = unreal.AssetImportTask()
    task.set_editor_property('automated', True)
    task.set_editor_property('destination_name', '')
    task.set_editor_property('destination_path', destination_path)
    task.set_editor_property('filename', filename)
    task.set_editor_property('replace_existing', True)
    task.set_editor_property('save', True)
    return task


def executeImportTasks(tasks):
    unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)






UE4_Python_自动化导入素材脚本_音频_图片_FBX_第5张图片

你可能感兴趣的:(UE4_Python,UE4)