Skip to content

CopyCoordinator

ClassAssetInventoryAssetInventory.Editor
public static class CopyCoordinator

Coordinates asset copy operations across parallel tasks to prevent duplicate work, race conditions, and excessive AssetDatabase.Refresh() calls. Uses smart caching with reference counting and file-existence validation.

public static Task<string> AcquireOrCopy(string guid, string targetFolder, Func<Task<string>> copyFunc)

Attempts to acquire a copy operation for the given GUID. If another operation is in-flight for the same GUID+folder, awaits it. If already completed and valid, returns the cached path. Otherwise, starts the copy operation.

Parameters

Name Type Description
guid System.String The GUID of the asset
targetFolder System.String The destination folder
copyFunc System.Func{System.Threading.Tasks.Task{System.String}} The function to execute the actual copy

Returns

System.Threading.Tasks.Task{System.String} — The target path of the copied file

public static string ValidateAndGet(string guid, string targetFolder)

Validates and returns a cached path if the file still exists.

Parameters

Name Type Description
guid System.String The GUID of the asset
targetFolder System.String The destination folder

Returns

System.String — The cached path if valid, null otherwise

public static void Invalidate(string guid, string targetFolder)

Invalidates a specific cached entry by GUID and folder.

Parameters

Name Type Description
guid System.String
targetFolder System.String
public static void InvalidateFolder(string folderPath)

Invalidates all cached entries for files in the specified folder.

Parameters

Name Type Description
folderPath System.String The folder path (can be partial, will match contains)
public static void Reset()

Clears all cached entries. Call this at the start of bulk operations to ensure fresh state.

public static CopyCoordinator.FileCategory ClassifyFile(string sourcePath, string guid, string fileType)

Classifies a file based on its metadata availability.

Parameters

Name Type Description
sourcePath System.String The source file path
guid System.String The known GUID, if any
fileType System.String The file extension without dot

Returns

AssetInventory.CopyCoordinator.FileCategory — The file category

public static bool IsScriptType(string fileType)

Checks if the file type is a script-related type that triggers domain reload.

Parameters

Name Type Description
fileType System.String

Returns

System.Boolean — No return description is available.

public static (int totalEntries, int inFlight, int completed) GetStats()

Gets the current cache statistics for debugging/monitoring.

Returns

System.ValueTuple{System.Int32,System.Int32,System.Int32} — No return description is available.