2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > UE4之脚本导入fbx

UE4之脚本导入fbx

时间:2022-01-01 21:47:30

相关推荐

UE4之脚本导入fbx

参考:

/longyanbuhui/article/details/88929977

/video/BV1b4411r7kX?p=3

/zh-CN/Engine/Editor/ScriptingAndAutomation/Python/index.html

内容:

折腾了一晚上,主要就是这个路径的问题,记录一下。

python脚本如下:

import unrealdef build_static_mesh_import_options():"""构建导入静态网格选项:return: options 导入静态网格选项"""options = unreal.FbxImportUI()options.set_editor_property('import_mesh', True)options.set_editor_property('import_materials', True)options.set_editor_property('import_as_skeletal', False) # 是否当作骨骼物体来导入options.static_mesh_import_data.set_editor_property('import_translation', unreal.Vector(0.0, 0.0, 0.0))options.static_mesh_import_data.set_editor_property('import_rotation', unreal.Rotator(0, 0, 0))options.static_mesh_import_data.set_editor_property('import_uniform_scale', 1.0)options.static_mesh_import_data.set_editor_property('combine_meshes', True)options.static_mesh_import_data.set_editor_property('generate_lightmap_u_vs', True)options.static_mesh_import_data.set_editor_property('auto_generate_collision', True)return optionsdef creatImportTask(filename, destination_path, options=None):""":param filename: 导入的文件的路径 eg: 'F:/workPlace/Scripts/MyTexture.TGA':param destination_path: 导出后置产要放在什么位置 eg: '/GAME/Texture':param options: 导入置产属性,静态属性可由函数build_static_mesh_import_options获得,骨骼属性可由build_skeletal_mesh_import_options获得:return: Task 返回一个导入任务"""importtask = unreal.AssetImportTask()importtask.set_editor_property("automated", True)importtask.set_editor_property('destination_name', 'my_asset')importtask.set_editor_property('destination_path', destination_path)importtask.set_editor_property('filename', filename)importtask.set_editor_property('replace_existing', True) # 覆盖现有文件importtask.set_editor_property('options', options) # 覆盖现有文件importtask.set_editor_property('save', True)return importtaskdef execute_import_tasks(tasks):"""执行导入任务:param tasks: array 任务池:return: True"""asset_tools = unreal.AssetToolsHelpers.get_asset_tools() # 创建一个资产工具asset_tools.import_asset_tasks([tasks]) # 导入资产import_files = "C:\\Users\\41132\\Desktop\\project\\assect\\111.FBX"destination_path = "/Game/fbx"options = build_static_mesh_import_options()import_task = creatImportTask(import_files , destination_path , options )execute_import_tasks(import_task )

注意事项:

下面两个路径是等价的,不能写错了,不然总是崩溃:

第二:资产的名称,这个是等价的,不要写错了

至于怎么运行,完全参考官方文档。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。