Skip to content

Commit 62cc27b

Browse files
committed
- add the deleteing unused assets script
- edit the README file
1 parent 25452b5 commit 62cc27b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Assets/DeleteUnusedAssets.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# _
2+
# (_)
3+
# _ __ ___ __ _ _ __ ___ ___ _ __ _ ___ _ __ ___
4+
# | '_ ` _ \ / _` | '_ ` _ \ / _ \| '_ \| |/ _ \ '_ ` _ \
5+
# | | | | | | (_| | | | | | | (_) | | | | | __/ | | | | |
6+
# |_| |_| |_|\__,_|_| |_| |_|\___/|_| |_|_|\___|_| |_| |_|
7+
# www.mamoniem.com
8+
# www.ue4u.xyz
9+
#Copyright 2019 Muhammad A.Moniem (@_mamoniem). All Rights Reserved.
10+
#
11+
12+
import unreal
13+
14+
workingPath = "/Game/"
15+
16+
@unreal.uclass()
17+
class GetEditorAssetLibrary(unreal.EditorAssetLibrary):
18+
pass
19+
20+
editorAssetLib = GetEditorAssetLibrary();
21+
22+
allAssets = editorAssetLib.list_assets(workingPath, True, False)
23+
24+
processingAssetPath = ""
25+
allAssetsCount = len(allAssets)
26+
if ( allAssetsCount > 0):
27+
with unreal.ScopedSlowTask(allAssetsCount, processingAssetPath) as slowTask:
28+
slowTask.make_dialog(True)
29+
for asset in allAssets:
30+
processingAssetPath = asset
31+
deps = editorAssetLib.find_package_referencers_for_asset(asset, False)
32+
if (len(deps) <= 0):
33+
print ">>> Deleting >>> %s" % asset
34+
editorAssetLib.delete_asset(asset)
35+
if slowTask.should_cancel():
36+
break
37+
slowTask.enter_progress_frame(1, processingAssetPath)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Don't forget to follow this repo, [YouTube](http://www.youtube.com/channel/UCBBc
1818

1919
## Assets ##
2020

21-
- **[ReportUnusedAssets.py](https://github.com/mamoniem/UnrealEditorPythonScripts/blob/master/Assets/ReportUnusedAssets.py)** Running this script will look through all the project folders, and add to the log the assets that were found not in a use, or in another work, the assets that have no dependency with any other project files.
21+
- **[ReportUnusedAssets.py](https://github.com/mamoniem/UnrealEditorPythonScripts/blob/master/Assets/ReportUnusedAssets.py)** Running this script will look through all the project folders, and add to the log the assets that were found not in a use, or in another word, the assets that have no dependency with any other project files.
22+
- **[DeleteUnusedAssets.py](https://github.com/mamoniem/UnrealEditorPythonScripts/blob/master/Assets/DeleteUnusedAssets.py)** Running this script will look through all the project folders, and delete the assets that were found not in a use, or in another word, the assets that have no dependency with any other project files. Note that, running this script won't show a confirmation message or accepting dialogue box, it will force delete the assets right a way, so make sure to evaluate the change before submitting to your repo.
2223

2324
## Materials ##
2425
- **[CreateInstancesOfSelectedMaterial.py](https://github.com/mamoniem/UnrealEditorPythonScripts/blob/master/Materials/CreateInstancesOfSelectedMaterial.py)** Run on a selected single or multiple Material file(s) in order to generate material instances of it/them. The number of the final generated instances count can be set within the script before running, by changing the value of the variable *totalRequiredInstances*

0 commit comments

Comments
 (0)