Documentation

Unity Engine

Download Unity

Unity Engine

Revert

Starts a task that reverts a list of assets, undoing any changes since the last sync.
Read time 2 minutesLast updated 11 days ago

Definition

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

assets

The list of assets to revert.

How to revert the changes. For more information, refer to RevertMode.

Returns

Type

Description

TaskThe 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

asset

The asset to revert.

How to revert the changes. For more information, refer to RevertMode.

Returns

Type

Description

TaskThe 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.