Skip to main content

Safe Deletion

Safe Deletion ensures you don't accidentally break your project by deleting assets or folders that are still referenced elsewhere.

Overview

The Safe Delete feature:

  • ✅ Scans for external references before deleting
  • ✅ Warns if deletion would break references
  • ✅ Only deletes if safe (no external referencers)
  • ✅ Cleans up empty parent folders automatically
  • ✅ Fixes redirectors after deletion

How It Works

graph TD
A[Select Folder] --> B[Scan Dependencies]
B --> C{Has External<br/>Referencers?}
C -->|Yes| D[Show Warning]
D --> E[Cancel Delete]
C -->|No| F[Confirm Delete]
F --> G{User<br/>Confirms?}
G -->|No| E
G -->|Yes| H[Delete Assets]
H --> I[Delete Empty Folders]
I --> J[Fix Redirectors]
J --> K[Complete]

Features

Dependency Checking

Before deletion, the system:

  1. Scans all assets in the folder
  2. Finds all referencers (what uses these assets)
  3. Separates internal vs external references
  4. Determines if deletion is safe

Safe to delete:

  • No external references
  • Only internal references (within same folder)
  • No dependencies outside the folder

Not safe to delete:

  • Has external referencers (assets in other folders use it)
  • Would break references in Blueprints, Materials, etc.
  • Required by maps or other critical assets

Warning System

If deletion is unsafe:

❌ Cannot safely delete this folder

The following assets have external references:
• BP_Character (referenced by 3 Blueprints)
• M_Material (used in 5 Maps)
• T_Texture (referenced by 12 Materials)

Deleting would break these references.

Empty Folder Cleanup

After successful deletion:

  1. Check parent folders
  2. Delete any empty folders
  3. Recurse up the folder tree
  4. Stop when a non-empty folder is found

Redirector Management

After deletion:

  1. Fix any broken redirectors
  2. Update redirector paths
  3. Clean up redirector chains

Usage

From Content Browser

  1. Right-click a folder
  2. Select Elys Asset Tools → Safe Delete Folder
  3. Review the dependency scan results
  4. Confirm deletion if safe
  5. Cancellation if unsafe

Via Blueprint

// Get subsystem
UERP_AssetToolsEditorSubsystem* Subsystem =
GEditor->GetEditorSubsystem<UERP_AssetToolsEditorSubsystem>();

// Check if safe first
bool bSafe = Subsystem->IsFolderSafeToDelete("/Game/ToDelete");

if (bSafe)
{
// Proceed with deletion
bool bDeleted = Subsystem->SafeDeleteFolder("/Game/ToDelete");
}
else
{
UE_LOG(LogElysAssetTools, Warning, TEXT("Folder has external references!"));
}

Via C++

// Check safety
FERP_AssetDependencyScanResult ScanResult = Subsystem->ScanFolder("/Game/ToDelete");

// Count external referencers
int32 ExternalRefs = 0;
for (const FAssetData& Referencer : ScanResult.Referencers)
{
if (!Referencer.PackagePath.ToString().StartsWith("/Game/ToDelete"))
{
ExternalRefs++;
}
}

if (ExternalRefs == 0)
{
// Safe to delete
FAssetRegistryModule& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
// ... perform deletion
}

Safety Rules

What Makes a Folder Safe to Delete?

A folder is safe to delete if ALL of these are true:

  1. No external assets reference assets in this folder
  2. All dependencies are either:
    • Within the same folder (internal)
    • Engine content
    • Plugin content (not being deleted)
  3. No assets in this folder are:
    • Currently open in an editor
    • Loaded in memory by a running game
    • Part of a C++ class

What's Considered an External Reference?

External references:

  • Blueprints in other folders
  • Materials in other folders
  • Maps that include these assets
  • Data assets that reference these assets

NOT external references:

  • References within the same folder
  • Engine content references (always available)
  • Plugin content references (assuming plugins stay)

Best Practices

Before Deleting

  1. Run dependency scan - Understand what you're deleting
  2. Check referencers - Know what would be affected
  3. Commit to version control - Have a backup
  4. Consider moving instead - Deletion is permanent

Alternative: Move to Archive

Instead of deleting, consider:

// Move to archive folder instead of deleting
Subsystem->StartMoveAssets({"/Game/ToDelete"}, "/Game/Archive/Deleted");

This way:

  • Content is preserved
  • References still work
  • Can be recovered if needed
  • Can delete archive periodically

Verifying Safety Manually

// Get detailed dependency info
FERP_AssetDependencyScanResult Result = Subsystem->ScanFolder("/Game/MyFolder");

// Log all external referencers
for (const FAssetData& Referencer : Result.Referencers)
{
FString PackagePath = Referencer.PackagePath.ToString();
if (!PackagePath.StartsWith("/Game/MyFolder"))
{
UE_LOG(LogElysAssetTools, Warning, TEXT("External referencer: %s"), *Referencer.AssetName.ToString());
}
}

Delete Empty Folders

Separate feature for cleaning up empty folders:

From Content Browser

  1. Right-click a folder
  2. Select Elys Asset Tools → Delete Empty Folders
  3. Scans recursively for empty folders
  4. Deletes all empty subfolders

What's Considered Empty?

A folder is empty if it contains:

  • No assets
  • No subfolders with assets
  • Only redirectors (optionally)

Via Blueprint

// Delete all empty folders under a path
Subsystem->DeleteEmptyFolders("/Game/Content");

Via C++

// Recursively find and delete empty folders
void DeleteEmptyFoldersRecursive(const FString& BasePath)
{
IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry").Get();

TArray<FString> SubPaths;
AssetRegistry.GetSubPaths(BasePath, SubPaths, false);

for (const FString& SubPath : SubPaths)
{
// Recurse first
DeleteEmptyFoldersRecursive(SubPath);

// Check if now empty
TArray<FAssetData> Assets;
AssetRegistry.GetAssetsByPath(*SubPath, Assets, false);

if (Assets.Num() == 0)
{
// Delete folder (UE Editor function)
IFileManager::Get().DeleteDirectory(*SubPath, false, true);
}
}
}

Troubleshooting

"Cannot delete - has references" but folder appears unused

Possible causes:

  1. Soft references - Check for soft object references
  2. Redirectors - Old redirectors may still point here
  3. C++ references - Native code may reference these assets
  4. Recently moved - Asset Registry may not be updated

Solutions:

// Force refresh Asset Registry
FAssetRegistryModule::AssetCreated(Asset);
FAssetRegistryModule::AssetDeleted(Asset);

Deletion succeeds but references break

This shouldn't happen with Safe Delete, but if it does:

  1. Use Undo (Ctrl+Z) immediately
  2. Restore from version control
  3. Re-import deleted assets
  4. Fix up redirectors

Cannot delete specific asset

If a single asset blocks deletion:

  1. Find what references it (use Dependency Scanner)
  2. Remove those references first
  3. Or move the problematic asset elsewhere
  4. Then delete the folder

API Reference

See Subsystem API for complete API documentation.

Next Steps