Revert
Starts a task that reverts a list of assets, undoing any changes since the last sync.
阅读时间2 分钟最后更新于 11 天前
Definition
- Type: Method
- Namespace: UnityEditor.VersionControl
- Assembly: UnityEditor.CoreModule
Revert(AssetList, RevertMode)
Starts a task that reverts a list of assets, undoing any changes since the last sync.
public static Task Revert(AssetList assets, RevertMode mode)
Parameters
Returns
Type | Description |
|---|---|
| Task | The task that reverts the assets. |
Remarks
The last sync is usually the last time you called Provider.GetLatest, but it can differ if you also use an external version control client. The revert mode controls which changes the task reverts. 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/Revert")] public static void ExampleRevert() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs")); Task t = Provider.Revert(assets, RevertMode.Normal); t.Wait(); }}
Revert(Asset, RevertMode)
Starts a task that reverts a single asset, undoing any changes since the last sync.
public static Task Revert(Asset asset, RevertMode mode)
Parameters
Returns
Type | Description |
|---|---|
| Task | The task that reverts the asset. |
Remarks
The last sync is usually the last time you called Provider.GetLatest, but it can differ if you also use an external version control client. The revert mode controls which changes the task reverts. After the task completes, Unity doesn't refresh the Asset Database automatically. To refresh it, call AssetDatabase.Refresh.