1 新建项目,开启插件
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190331154307242.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xvbmd5YW5idWh1aQ==,size_16,color_FFFFFF,t_70)
2 项目设置—>Python
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190331154519659.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xvbmd5YW5idWh1aQ==,size_16,color_FFFFFF,t_70)
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)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190331154723918.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xvbmd5YW5idWh1aQ==,size_16,color_FFFFFF,t_70)
4 依次执行
import AssetFunctions as AF
AF.ImportMyAssets()
5 然后,素材自动导入到项目中
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190331155012433.png)
导入音频和图片
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)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190725163220866.png)