Last active
March 14, 2024 09:25
-
-
Save aobond2/42c14cea52fe7fc04dce8897e1de81b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unreal | |
# Change this with desired LOD level | |
targetLOD = 0 | |
# Change this with target folder for GLB output | |
targetFolder = "C:\\GLBExportTest\\" | |
targetFileFormat = ".glb" | |
selectedAssets = unreal.EditorUtilityLibrary.get_selected_assets() | |
numAssets = len(selectedAssets) | |
def exportGLB(): | |
for asset in selectedAssets: | |
# Get folder name | |
directoryForAsset = unreal.Paths.get_path(asset.get_path_name()) | |
folder = directoryForAsset.split("/")[-1] | |
mainBody = directoryForAsset.split("/")[-2] | |
individualFolder = mainBody + "\\" + folder + "\\" | |
task = unreal.AssetExportTask() | |
task.object = asset | |
task.filename = targetFolder + individualFolder + mainBody + "_" + folder + "_" + asset.get_name() + targetFileFormat | |
task.automated = True | |
task.replace_identical = True | |
task.exporter = unreal.GLTFSkeletalMeshExporter() | |
task.options = unreal.GLTFExportOptions() | |
task.options.default_level_of_detail = targetLOD | |
result = unreal.Exporter.run_asset_export_task(task) | |
print (task.filename) | |
exportGLB() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment