-
-
Notifications
You must be signed in to change notification settings - Fork 215
/
DeleteUnusedAssets.py
37 lines (31 loc) · 1.2 KB
/
DeleteUnusedAssets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# _
# (_)
# _ __ ___ __ _ _ __ ___ ___ _ __ _ ___ _ __ ___
# | '_ ` _ \ / _` | '_ ` _ \ / _ \| '_ \| |/ _ \ '_ ` _ \
# | | | | | | (_| | | | | | | (_) | | | | | __/ | | | | |
# |_| |_| |_|\__,_|_| |_| |_|\___/|_| |_|_|\___|_| |_| |_|
# www.mamoniem.com
# www.ue4u.xyz
#Copyright 2022 Muhammad A.Moniem (@_mamoniem). All Rights Reserved.
#
import unreal
workingPath = "/Game/"
@unreal.uclass()
class GetEditorAssetLibrary(unreal.EditorAssetLibrary):
pass
editorAssetLib = GetEditorAssetLibrary();
allAssets = editorAssetLib.list_assets(workingPath, True, False)
processingAssetPath = ""
allAssetsCount = len(allAssets)
if ( allAssetsCount > 0):
with unreal.ScopedSlowTask(allAssetsCount, processingAssetPath) as slowTask:
slowTask.make_dialog(True)
for asset in allAssets:
processingAssetPath = asset
deps = editorAssetLib.find_package_referencers_for_asset(asset, False)
if (len(deps) <= 0):
print (">>> Deleting >>> %s" % asset)
editorAssetLib.delete_asset(asset)
if slowTask.should_cancel():
break
slowTask.enter_progress_frame(1, processingAssetPath)