Assetdatebase is also a static class, and his role is to manage all the files of the project (typically "assets"). Intuitively, you can manage everything in the entire project window, such as adding, deleting, modifying files, and so on.
Here are a few that are often used:
Createasset: Creating Files
CreateFolder: Creating a Folder
Deleteasset: Deleting files
Getassetpath: Gets the relative position of the file relative to the directory where Assets is located, such as "Assets/images/test.png"
Loadassetatpath: Loading files
Refresh: Refreshes the entire project window
Saveassets: Save All Files
Example (implement right-click on a file or folder, select Myeditor/delete Asset menu, delete the selected file or folder):
123456789101112 |
using unityeditor; public class EditorCase1 { [MenuItem ( "Assets/myeditor/delete Asset" )] public static void casemenu () { var obj = selection.activeobject; var path = Assetdatabase.getassetpath (obj); assetdatabase.deleteasset (path); } } |
Unity Plugin Development--assetdatabase