Version: 2021.1
public static VersionControl.Task Delete (string assetProjectPath);
public static VersionControl.Task Delete (VersionControl.AssetList assets);
public static VersionControl.Task Delete (VersionControl.Asset asset);

参数

assetProjectPath The path to the asset that is to be deleted.
assets 要删除的资源列表。
asset 要删除的资源。

描述

Starts a task to delete an Asset or a list of Assets from the disk and from the version control system.

任务完成后,任务的结果将指出资源是否已被成功删除。

Note that after this operation is completed, Asset Database is not refreshed automatically. It can be updated by calling AssetDatabase.Refresh.

using System.Collections.Generic;
using UnityEditor;
using UnityEditor.VersionControl;
using UnityEngine;

public class EditorScript : MonoBehaviour { [MenuItem("Version Control/Delete")] public static void ExampleDelete() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs")); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs.meta")); Task t = Provider.Delete(assets); t.Wait(); } }