2023-11-12 15:09:22 +00:00
|
|
|
import os
|
|
|
|
import unreal
|
|
|
|
|
2023-11-13 00:51:12 +00:00
|
|
|
# Get The working Dir
|
|
|
|
root_folder = r'\done'
|
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
model_directory = dir_path + root_folder
|
|
|
|
print(model_directory)
|
2023-11-12 15:09:22 +00:00
|
|
|
|
|
|
|
# Get the AssetTools
|
|
|
|
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
|
|
|
|
|
2023-11-13 00:51:12 +00:00
|
|
|
# Iterate through .fbx files in the specified directory and its subdirectories
|
|
|
|
for root, dirs, files in os.walk(model_directory):
|
2023-11-12 15:09:22 +00:00
|
|
|
for file_name in files:
|
2023-11-13 00:51:12 +00:00
|
|
|
if file_name.endswith(".fbx"):
|
2023-11-12 15:09:22 +00:00
|
|
|
file_path = os.path.join(root, file_name)
|
|
|
|
|
|
|
|
# Extract relative path from the source directory
|
2023-11-13 00:51:12 +00:00
|
|
|
relative_path = os.path.relpath(file_path, model_directory)
|
2023-11-12 15:09:22 +00:00
|
|
|
|
|
|
|
# Construct the destination path in the Content Browser
|
2024-01-17 20:11:54 +00:00
|
|
|
destination_path = "/Game/Mods/YourModName/Units/" + os.path.splitext(relative_path.replace("\\", "/"))[0]
|
2023-11-12 15:09:22 +00:00
|
|
|
|
|
|
|
# Create an import task
|
|
|
|
import_task = unreal.AssetImportTask()
|
|
|
|
import_task.filename = file_path
|
|
|
|
import_task.destination_path = destination_path
|
2024-01-17 20:11:54 +00:00
|
|
|
import_task.automated = True
|
2023-11-12 15:09:22 +00:00
|
|
|
|
2023-11-13 00:51:12 +00:00
|
|
|
# Import the .fbx file
|
2023-11-12 15:09:22 +00:00
|
|
|
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
|