CheckoutIsValid
Checks whether at least one asset in a list can be checked out.
阅读时间3 分钟最后更新于 11 天前
Definition
- Type: Method
- Namespace: UnityEditor.VersionControl
- Assembly: UnityEditor.CoreModule
CheckoutIsValid(AssetList)
Checks whether at least one asset in a list can be checked out.
public static bool CheckoutIsValid(AssetList assets)
Parameters
The list of assets to check.
Returns
Type | Description |
|---|---|
| bool | True if Provider.Checkout is a valid operation for at least one of the assets. Otherwise, false. |
Remarks
Use this method to check whether a checkout can succeed before you start one. The check passes if at least one asset can be checked out. This overload checks with CheckoutMode.Exact. To check only asset files or only .meta files, use the overload that takes a CheckoutMode.
CheckoutIsValid(AssetList, CheckoutMode)
Checks whether at least one asset in a list can be checked out, for the specified files.
public static bool CheckoutIsValid(AssetList assets, CheckoutMode mode)
Parameters
The list of assets to check.
The files to check: the asset file, its .meta file, or both. For more information, refer to CheckoutMode.
Returns
Type | Description |
|---|---|
| bool | True if Provider.Checkout is a valid operation for at least one of the assets. Otherwise, false. |
Remarks
Use this method to check whether a checkout can succeed before you start one. The check passes if at least one asset can be checked out. Use the mode to narrow the check to a type of file. For example, to check only .meta files and ignore the state of the asset files, use CheckoutMode.Meta.
using System.Collections.Generic;using UnityEditor;using UnityEditor.VersionControl;using UnityEngine;public class EditorScript : MonoBehaviour{ [MenuItem("Version Control/CheckoutIsValid")] public static void ExampleCheckoutIsValid() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs.meta")); Debug.Log(Provider.CheckoutIsValid(assets, CheckoutMode.Meta)); }}
This example logs true if the .meta file of can be checked out.
ExampleAsset.csCheckoutIsValid(Asset)
Checks whether a single asset can be checked out.
public static bool CheckoutIsValid(Asset asset)
Parameters
The asset to check.
Returns
Type | Description |
|---|---|
| bool | True if Provider.Checkout is a valid operation for the asset. Otherwise, false. |
Remarks
Use this method to check whether a checkout can succeed before you start one. The check passes if at least one asset can be checked out. This overload checks with CheckoutMode.Exact. To check only asset files or only .meta files, use the overload that takes a CheckoutMode.
CheckoutIsValid(Asset, CheckoutMode)
Checks whether a single asset can be checked out, for the specified files.
public static bool CheckoutIsValid(Asset asset, CheckoutMode mode)
Parameters
The asset to check.
The files to check: the asset file, its .meta file, or both. For more information, refer to CheckoutMode.
Returns
Type | Description |
|---|---|
| bool | True if Provider.Checkout is a valid operation for the asset. Otherwise, false. |
Remarks
Use this method to check whether a checkout can succeed before you start one. The check passes if at least one asset can be checked out. Use the mode to narrow the check to a type of file. For example, to check only .meta files and ignore the state of the asset files, use CheckoutMode.Meta.