37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import os
|
|
import unreal
|
|
|
|
# Set the path to the directory containing your .gltf files
|
|
gltf_directory = "D:/PayDay2/done"
|
|
|
|
# Get the AssetTools
|
|
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
|
|
|
|
# Iterate through .gltf files in the specified directory and its subdirectories
|
|
for root, dirs, files in os.walk(gltf_directory):
|
|
for file_name in files:
|
|
if file_name.endswith(".gltf"):
|
|
file_path = os.path.join(root, file_name)
|
|
|
|
# Extract relative path from the source directory
|
|
relative_path = os.path.relpath(file_path, gltf_directory)
|
|
|
|
# Construct the destination path in the Content Browser
|
|
destination_path = "/Game/units/" + os.path.splitext(relative_path)[0]
|
|
|
|
# Create an import task
|
|
import_task = unreal.AssetImportTask()
|
|
import_task.filename = file_path
|
|
import_task.destination_path = destination_path
|
|
|
|
# Import the .gltf file
|
|
asset_tools.import_asset_tasks([import_task])
|
|
|
|
# Print feedback
|
|
print(f"Importing: {file_path}")
|
|
print(f"Destination Path: {destination_path}")
|
|
print("------")
|
|
|
|
print("Batch import complete.")
|
|
|
|
# Add that after importing all the modlels to remove redundent materials and combine them all into one per unique material |