forked from mamoniem/UnrealEditorPythonScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnifyAllAssetsDuplicates.py
More file actions
59 lines (46 loc) · 2.17 KB
/
UnifyAllAssetsDuplicates.py
File metadata and controls
59 lines (46 loc) · 2.17 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# _
# (_)
# _ __ ___ __ _ _ __ ___ ___ _ __ _ ___ _ __ ___
# | '_ ` _ \ / _` | '_ ` _ \ / _ \| '_ \| |/ _ \ '_ ` _ \
# | | | | | | (_| | | | | | | (_) | | | | | __/ | | | | |
# |_| |_| |_|\__,_|_| |_| |_|\___/|_| |_|_|\___|_| |_| |_|
# 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()
processAssetPath = ""
allAssets = editorAssetLib.list_assets(workingPath, True, False)
allAssetsCount = len(allAssets)
with unreal.ScopedSlowTask(allAssetsCount, processAssetPath) as slowTask:
slowTask.make_dialog(True)
for processAsset in allAssets:
_processAssetData = editorAssetLib.find_asset_data(processAsset)
_processAsset = _processAssetData.get_asset()
_processAssetName = _processAssetData.get_asset().get_name()
processAssetPath = _processAssetData.get_asset().get_path_name()
assetsMatching = []
for asset in allAssets:
_assetData = editorAssetLib.find_asset_data(asset)
_assetName = _assetData.get_asset().get_name()
if (_assetName == _processAssetName):
if (asset != processAssetPath):
_assetLoaded = editorAssetLib.load_asset(asset)
assetsMatching.append(_assetData.get_asset())
if (len(assetsMatching) != 0):
editorAssetLib.consolidate_assets(_processAsset, assetsMatching)
print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
print (">>> The unifing process completed for %d assets" % len(assetsMatching))
print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
else:
print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
print (">>> There were no duplicates found for the selected asset")
print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
if slowTask.should_cancel():
break
slowTask.enter_progress_frame(1, asset)