path | 要删除的资产或文件夹的项目相对路径。 |
bool 如果资产已成功删除,则返回 true;如果资产不存在或无法删除,则返回 false。
将指定的资产或文件夹移至 OS 垃圾箱。
路径应相对于项目文件夹,例如: "Assets/MyTextures/hello.png"
其他资源: AssetDatabase.DeleteAsset, AssetDatabase.DeleteAssets, AssetDatabase.MoveAssetsToTrash.
using UnityEngine; using UnityEditor;
//Note: When moving many Assets to trash and using version control integration it's better to use MoveAssetsToTrash method for performance reasons public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Move All Files In Folder To Trash")] static void MoveAllFilesInFolderToTrash() { string[] unusedFolder = { "Assets/Unused" }; foreach (var asset in AssetDatabase.FindAssets("", unusedFolder)) { var path = AssetDatabase.GUIDToAssetPath(asset); AssetDatabase.MoveAssetToTrash(path); } } }