Guest User

Untitled

a guest
Sep 4th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. def import_assets():
  2.     files = glob.glob(fbx_base_path+"*fbx")
  3.     mesh_import_tasks = []
  4.     for file in files:
  5.         mesh_import_tasks.append(build_mesh_import_task(file, '/Game/Meshes'))
  6.     unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(mesh_import_tasks)
  7.  
  8.  
  9. def build_mesh_import_task(filename, destination_path, destination_name=''):
  10.  
  11.  
  12.     # the task, and the additional fbx options, since it is a mesh
  13.     task = unreal.AssetImportTask()
  14.     fbx_options = unreal.FbxImportUI()
  15.  
  16.  
  17.     # basic task properties
  18.     task.set_editor_property('automated', True)
  19.     task.set_editor_property('filename', filename)
  20.     task.set_editor_property('destination_path', destination_path)
  21.     # if destination_name is '' it will use the on-disk filename
  22.     task.set_editor_property('destination_name', destination_name)
  23.     task.set_editor_property('replace_existing', True)
  24.     task.set_editor_property('save', True)
  25.     task.set_editor_property('options', fbx_options)
  26.  
  27.  
  28.     # additional options specifically for meshes
  29.     fbx_options.set_editor_property('import_mesh', True)
  30.     fbx_options.set_editor_property('import_textures', True)
  31.     fbx_options.set_editor_property('import_as_skeletal', False)
  32.     fbx_options.set_editor_property('import_materials', True)
  33.  
  34.  
  35.     # settings specifically for static meshes
  36.     fbx_options.static_mesh_import_data.set_editor_property('combine_meshes', False)
  37.     fbx_options.static_mesh_import_data.set_editor_property('generate_lightmap_u_vs', False)
  38.     return task
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment