Delete
Starts a task that deletes the asset at a project path from disk and from version control.
阅读时间1 分钟最后更新于 11 天前
Definition
- Type: Method
- Namespace: UnityEditor.VersionControl
- Assembly: UnityEditor.CoreModule
Delete(string)
Starts a task that deletes the asset at a project path from disk and from version control.
public static Task Delete(string assetProjectPath)
Parameters
The project-relative path of the asset to delete.
Returns
Type | Description |
|---|---|
| Task | The task that deletes the asset. |
Remarks
When the task completes, its Task.resultCode shows whether the deletion succeeded. After the task completes, Unity doesn't refresh the Asset Database automatically. To refresh it, call AssetDatabase.Refresh.
Delete(AssetList)
Starts a task that deletes a list of assets from disk and from version control.
public static Task Delete(AssetList assets)
Parameters
The list of assets to delete.
Returns
Type | Description |
|---|---|
| Task | The task that deletes the assets. |
Remarks
When the task completes, its Task.resultCode shows whether the deletion succeeded. After the task completes, Unity doesn't refresh the Asset Database automatically. To refresh it, call AssetDatabase.Refresh.
Examples
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(); }}
Delete(Asset)
Starts a task that deletes a single asset from disk and from version control.
public static Task Delete(Asset asset)
Parameters
The asset to delete.
Returns
Type | Description |
|---|---|
| Task | The task that deletes the asset. |
Remarks
When the task completes, its Task.resultCode shows whether the deletion succeeded. After the task completes, Unity doesn't refresh the Asset Database automatically. To refresh it, call AssetDatabase.Refresh.