Download

Setting compression settings on newly-imported textures?

Hi, I’m trying to automate the import process for various textures.

I assumed that the path to do this would be to create a TextureFactory for each compression settings like so:


texFactory_orm.set_editor_property('compression_settings', unreal.TextureCompressionSettings.TC_MASKS)

and then assign that factory conditionally to the AssetImportTask:


def build_texture_import_task(filename, destination_path, destination_name='', replace_existing=False):
    task = unreal.AssetImportTask()
    
    texname = os.path.splitext(os.path.basename(filename))[0]
    if texname.endswith('_N'):
        task.set_editor_property('factory', texFactory_normal)
    elif texname.endswith('_ORM'):
        task.set_editor_property('factory', texFactory_orm)
    elif texname.endswith('_H'):
        task.set_editor_property('factory', texFactory_height)
    else:
        task.set_editor_property('factory', texFactory_standard)

    task.set_editor_property('automated', True)
    task.set_editor_property('filename', filename)
    task.set_editor_property('destination_path', destination_path)
    task.set_editor_property('destination_name', destination_name)
    task.set_editor_property('replace_existing', replace_existing)
    task.set_editor_property('save', True)
    return task

but… this doesn’t work.

What am I doing wrong? There’s very little documentation I can find about texture import settings. There doesn’t seem to be a “FbxImportUI” equivalent.

Thanks in advance!

Unfortunately I do not have an answer for you. I tried doing the same thing with the same negative results. If you haven’t already resorted to this workaround I just ended up specifying the compression settings on the textures after import. It’s a bit unsatisfying as it seems like specifying it in the factory should work, but it gets me what I need.


imported_texture.set_editor_property('compression_settings', unreal.TextureCompressionSettings.TC_MASKS)