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

3 篇文章 2 订阅

1 新建项目,开启插件
在这里插入图片描述
2 项目设置—>Python
在这里插入图片描述
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)


在这里插入图片描述

4 依次执行

 import AssetFunctions as AF
 AF.ImportMyAssets()

5 然后,素材自动导入到项目中
在这里插入图片描述

导入音频和图片

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)






在这里插入图片描述

  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值