Skip to content

Commit

Permalink
Merge pull request #13 from ogxd/#8
Browse files Browse the repository at this point in the history
Improve performance when adding / deleting / updating several assets …
  • Loading branch information
ogxd authored Jul 8, 2022
2 parents b9cce31 + 986cd64 commit e6ab235
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Editor/AssetProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public static void Init()
/// </summary>
private static void OnUpdate()
{
while (Actions.Count > 0) {
Actions.Dequeue()?.Invoke();
if (Actions.Count > 0) {
while (Actions.Count > 0) {
Actions.Dequeue()?.Invoke();
}
ProjectCurator.SaveDatabase();
}
}

Expand All @@ -35,7 +38,6 @@ static string[] OnWillSaveAssets(string[] paths)
var removedAsset = ProjectCurator.RemoveAssetFromDatabase(path);
ProjectCurator.AddAssetToDatabase(path, removedAsset?.referencers);
}
ProjectCurator.SaveDatabase();
});
}
return paths;
Expand All @@ -46,16 +48,16 @@ static void OnWillCreateAsset(string assetName)
if (ProjectCuratorData.IsUpToDate) {
Actions.Enqueue(() => {
ProjectCurator.AddAssetToDatabase(assetName);
ProjectCurator.SaveDatabase();
});
}
}

static AssetDeleteResult OnWillDeleteAsset(string assetName, RemoveAssetOptions removeAssetOptions)
{
if (ProjectCuratorData.IsUpToDate) {
ProjectCurator.RemoveAssetFromDatabase(assetName);
ProjectCurator.SaveDatabase();
Actions.Enqueue(() => {
ProjectCurator.RemoveAssetFromDatabase(assetName);
});
}
return AssetDeleteResult.DidNotDelete;
}
Expand All @@ -66,7 +68,6 @@ static AssetMoveResult OnWillMoveAsset(string sourcePath, string destinationPath
Actions.Enqueue(() => {
ProjectCurator.RemoveAssetFromDatabase(sourcePath);
ProjectCurator.AddAssetToDatabase(destinationPath);
ProjectCurator.SaveDatabase();
});
}
return AssetMoveResult.DidNotMove;
Expand Down

0 comments on commit e6ab235

Please sign in to comment.