Revert
Reverts the specified assets by undoing any changes done since the last time you synced.
Read time 2 minutesLast updated 8 days ago
Definition
- Type: Method
- Namespace: UnityEditor.VersionControl
- Assembly: UnityEditor.CoreModule
Revert(AssetList, RevertMode)
Reverts the specified assets by undoing any changes done since the last time you synced.
public static Task Revert(AssetList assets, RevertMode mode)
Parameters
Returns
Type | Description |
|---|---|
| Task |
Remarks
The last sync time is usually when Provider.GetLatest was last issued but may differ if an external version control client is used at the same time.
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/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(); }}
Provider.Revert can be used with two different revert modes - normal and unchanged. The normal revert mode reverts all of the local changes made while the unchanged mode only reverts files that haven't been modified yet.
Revert(Asset, RevertMode)
Reverts the specified assets by undoing any changes done since the last time you synced.
public static Task Revert(Asset asset, RevertMode mode)
Parameters
Returns
Type | Description |
|---|---|
| Task |
Remarks
The last sync time is usually when Provider.GetLatest was last issued but may differ if an external version control client is used at the same time.
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/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(); }}
Provider.Revert can be used with two different revert modes - normal and unchanged. The normal revert mode reverts all of the local changes made while the unchanged mode only reverts files that haven't been modified yet.