Delete unused assets in Unreal Engine

This Python-script is used to remove unused assets from the Unreal Engine project.

# This is a sample Python script.


# Press Shift+F10 to execute it or replace it with your code.

# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import os

import sys

import unreal as ue


DIRECTORY = '/Game/StarterContent/'


editor = ue.EditorAssetLibrary()



def get_unused_assets(directory):

    unused_assets = []

    is_continue = True

    while is_continue:

        is_continue = False

        assets = editor.list_assets(directory)

        if len(assets) > 0:

            with ue.ScopedSlowTask(len(assets), 'Begin...') as slow_task:


                for asset in assets:

                    dependencies = editor.find_package_referencers_for_asset(asset)

                    if (len(dependencies) == 0 or all_in_array(unused_assets, dependencies) or

                            asset_equal_dependencies(asset, dependencies)) and asset not in unused_assets:

                        is_continue = True


                    if slow_task.should_cancel():         # True if the user has pressed Cancel in the UI



    return unused_assets



def all_in_array(array, need):

    for n in need:

        n = n + '.' + os.path.basename(n)

        if n not in array:

            return False

    return True



def asset_equal_dependencies(asset, dependencies):

    return asset == dependencies[0] + '.' + os.path.basename(dependencies[0])



def delete(deletes, is_delete=False):

    if not is_delete:

        ue.log('The argument "delete" is required to delete')

    with ue.ScopedSlowTask(len(deletes), 'Delete...') as slow_task:

        for asset in deletes:

            ue.log('DELETE: ' + asset)

            if is_delete:


            if slow_task.should_cancel():


            slow_task.enter_progress_frame(1, asset)



def delete_empty_folders(directory):

    registry = ue.AssetRegistryHelpers().get_asset_registry()

    directories = registry.get_sub_paths(directory, True)


    for directory in directories:

        if editor.does_directory_exist(directory) and not registry.has_assets(directory):

            ue.log('DELETE DIRECTORY: ' + directory)




# Press the green button in the gutter to run the script.

if __name__ == '__main__':

    delete_assets = get_unused_assets(DIRECTORY)

    if len(sys.argv) > 1:

        arg = sys.argv[1]

        if arg == 'delete':

            delete(delete_assets, True)






It might be interesting

Pioneer’s PDP-LX508D

As Pioneer always states about its goal to have the complete gratification of every Pioneer’s customer by offering novelties in those devices which others are also producing but not according to the quality that is a practice of Pioneer’s products.

Cloud Computing Pros and Cons

The internet is responsible for changing the way we do many things, from shopping, to transferring money between bank accounts, advertising our own products or services, doing business 24 hours a day, finding a date, communicating on a personal or business level or getting the latest information on anything we’re interested in.

AMD introduced a budget gaming graphics card Radeon RX 6500XT for $199

AMD officially announced Radeon RX 6500XT, a new gaming graphics card for the budget segment, at the presentation before the CES 2022 exhibition.