RevertIsValid
Checks whether at least one asset in a list can be reverted with the specified revert mode.
阅读时间1 分钟最后更新于 11 天前
Definition
- Type: Method
- Namespace: UnityEditor.VersionControl
- Assembly: UnityEditor.CoreModule
RevertIsValid(AssetList, RevertMode)
Checks whether at least one asset in a list can be reverted with the specified revert mode.
public static bool RevertIsValid(AssetList assets, RevertMode mode)
Parameters
Returns
Type | Description |
|---|---|
| bool | True if Provider.Revert is a valid operation for at least one of the assets. Otherwise, false. |
Remarks
Use this method to check whether a revert can succeed before you start one. Which files the check includes depends on the mode. RevertMode.Unchanged checks only files that are checked out or locked locally. RevertMode.Normal also checks files that are added or deleted locally.
Examples
using System.Collections.Generic;using UnityEditor;using UnityEditor.VersionControl;using UnityEngine;public class EditorScript : MonoBehaviour{ [MenuItem("Version Control/RevertIsValid")] public static void ExampleRevertIsValid() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs")); Debug.Log(Provider.RevertIsValid(assets, RevertMode.Normal)); }}
RevertIsValid(Asset, RevertMode)
Checks whether a single asset can be reverted with the specified revert mode.
public static bool RevertIsValid(Asset asset, RevertMode mode)
Parameters
Returns
Type | Description |
|---|---|
| bool | True if Provider.Revert is a valid operation for the asset. Otherwise, false. |
Remarks
Use this method to check whether a revert can succeed before you start one. Which files the check includes depends on the mode. RevertMode.Unchanged checks only files that are checked out or locked locally. RevertMode.Normal also checks files that are added or deleted locally.