Skip to content

Instantly share code, notes, and snippets.

@CGLion
Last active August 17, 2020 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGLion/5b6d3ea5b3835a9549f79ef7be21491c to your computer and use it in GitHub Desktop.
Save CGLion/5b6d3ea5b3835a9549f79ef7be21491c to your computer and use it in GitHub Desktop.
Python for UE4 - import assets
from os import listdir
from os.path import isfile, join
import unreal
dir = "D:\\"
files = [f for f in listdir(dir) if isfile(join(dir, f)) and f[-3:]=='jpg']
AssetTools = unreal.AssetToolsHelpers.get_asset_tools()
import_tasks = []
for f in files:
print join(dir, f)
AssetImportTask = unreal.AssetImportTask()
AssetImportTask.set_editor_property('filename', join(dir, f))
AssetImportTask.set_editor_property('destination_path', '/Game/Textures')
AssetImportTask.set_editor_property('save', True)
import_tasks.append(AssetImportTask)
AssetTools.import_asset_tasks(import_tasks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment