mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Added another action to delete unused assets
This commit is contained in:
parent
6583525e42
commit
465101c639
3 changed files with 34 additions and 3 deletions
|
|
@ -750,7 +750,7 @@ def replace_geometry_cache_actors(old_assets, new_assets, selected):
|
||||||
comp.set_geometry_cache(new_mesh)
|
comp.set_geometry_cache(new_mesh)
|
||||||
|
|
||||||
|
|
||||||
def delete_previous_asset_if_unused(container, asset_content):
|
def delete_asset_if_unused(container, asset_content):
|
||||||
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
||||||
|
|
||||||
references = set()
|
references = set()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import unreal
|
||||||
|
|
||||||
|
from openpype.hosts.unreal.api.pipeline import delete_asset_if_unused
|
||||||
|
from openpype.pipeline import InventoryAction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteUnusedAssets(InventoryAction):
|
||||||
|
"""Delete all the assets that are not used in any level.
|
||||||
|
"""
|
||||||
|
|
||||||
|
label = "Delete Unused Assets"
|
||||||
|
icon = "trash"
|
||||||
|
color = "red"
|
||||||
|
order = 1
|
||||||
|
|
||||||
|
def process(self, containers):
|
||||||
|
allowed_families = ["model", "rig"]
|
||||||
|
|
||||||
|
for container in containers:
|
||||||
|
container_dir = container.get("namespace")
|
||||||
|
if container.get("family") not in allowed_families:
|
||||||
|
unreal.log_warning(
|
||||||
|
f"Container {container_dir} is not supported.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
asset_content = unreal.EditorAssetLibrary.list_assets(
|
||||||
|
container_dir, recursive=True, include_folder=False
|
||||||
|
)
|
||||||
|
|
||||||
|
delete_asset_if_unused(container, asset_content)
|
||||||
|
|
@ -5,7 +5,7 @@ from openpype.hosts.unreal.api.pipeline import (
|
||||||
replace_static_mesh_actors,
|
replace_static_mesh_actors,
|
||||||
replace_skeletal_mesh_actors,
|
replace_skeletal_mesh_actors,
|
||||||
replace_geometry_cache_actors,
|
replace_geometry_cache_actors,
|
||||||
delete_previous_asset_if_unused,
|
delete_asset_if_unused,
|
||||||
)
|
)
|
||||||
from openpype.pipeline import InventoryAction
|
from openpype.pipeline import InventoryAction
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ def update_assets(containers, selected):
|
||||||
|
|
||||||
unreal.EditorLevelLibrary.save_current_level()
|
unreal.EditorLevelLibrary.save_current_level()
|
||||||
|
|
||||||
delete_previous_asset_if_unused(sa_cont, old_content)
|
delete_asset_if_unused(sa_cont, old_content)
|
||||||
|
|
||||||
|
|
||||||
class UpdateAllActors(InventoryAction):
|
class UpdateAllActors(InventoryAction):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue