| guids | GUIDs of assets to be deleted from cache server. |
| deleteAllRevisions | Specify whether all artifact revisions of the asset kept by editor will be deleted from cache server. If false, only current artifact revision will be deleted. |
bool Returns true if all artifacts are successfully deleted from cache server.
Delete aritifacts from cache server with given GUID of the asset.
This method deletes remote artifacts of specified assets(with given GUIDs) from cache server. Please note that if the artifact to be deleted does not exist on the cache server, the deletion will be considered successful. You can use CacheServer.CheckArtifacts to check whether artifacts of an asset exist on cache server. More details of the deletion will be recorded in Editor Log.
using UnityEditor; using UnityEngine;
public static class RemoteCacheDeleter { // delete the remote cache for the selected asset [MenuItem("Assets/Delete Remote Cache", false, 20)] private static void DeleteRemoteCache() { string path = AssetDatabase.GetAssetPath(Selection.objects[0]);
if (!string.IsNullOrEmpty(path)) { string fileID = GetFileID(path); GUID[] guids = { new GUID(fileID) }; if (CacheServer.DeleteArtifacts(guids, false)) { Debug.Log($"Remote cache for {path} deleted successfully."); AssetDatabase.Refresh(); } else { Debug.LogWarning($"Failed to delete remote cache for {path}."); } } }
private static string GetFileID(string path) { return AssetDatabase.AssetPathToGUID(path); } }