Version: 2023.2
LanguageEnglish
  • C#

Provider.Revert

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static VersionControl.Task Revert(VersionControl.AssetList assets, VersionControl.RevertMode mode);

Declaration

public static VersionControl.Task Revert(VersionControl.Asset asset, VersionControl.RevertMode mode);

Parameters

assets The list of assets to be reverted.
asset The asset to be reverted.
mode How to revert the assets.

Description

Reverts the specified assets by undoing any changes done since the last time you synced.

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.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961