文档

Unity Engine

Unity Engine

CheckoutIsValid

Checks whether at least one asset in a list can be checked out.
阅读时间3 分钟最后更新于 11 天前

Definition

CheckoutIsValid(AssetList)

Checks whether at least one asset in a list can be checked out.
public static bool CheckoutIsValid(AssetList assets)

Parameters

assets

The list of assets to check.

Returns

Type

Description

boolTrue 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

assets

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

boolTrue 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
ExampleAsset.cs
can be checked out.

CheckoutIsValid(Asset)

Checks whether a single asset can be checked out.
public static bool CheckoutIsValid(Asset asset)

Parameters

asset

The asset to check.

Returns

Type

Description

boolTrue 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

asset

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

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