Documentation

Unity Engine

Unity Engine

Lock

Starts a task that locks or unlocks a list of assets for exclusive editing.
Read time 1 minuteLast updated 11 days ago

Definition

Lock(AssetList, bool)

Starts a task that locks or unlocks a list of assets for exclusive editing.
public static Task Lock(AssetList assets, bool locked)

Parameters

assets

The list of assets to lock or unlock.

locked

Set to true to lock the assets. Set to false to unlock them.

Returns

Type

Description

TaskThe task that locks or unlocks the assets.

Remarks

What a lock does depends on the version control system and server setup. It might prevent other people from editing the asset at all, or only prevent them from submitting it to the server.

Examples

using System.Collections.Generic;using UnityEditor;using UnityEditor.VersionControl;using UnityEngine;public class EditorScript : MonoBehaviour{ [MenuItem("Version Control/Lock")] public static void ExampleLock() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs")); Task t1 = Provider.Checkout(assets, CheckoutMode.Exact); t1.Wait(); Task t2 = Provider.Lock(assets, locked: true); t2.Wait(); }}

Lock(Asset, bool)

Starts a task that locks or unlocks a single asset for exclusive editing.
public static Task Lock(Asset asset, bool locked)

Parameters

asset

The asset to lock or unlock.

locked

Set to true to lock the asset. Set to false to unlock it.

Returns

Type

Description

TaskThe task that locks or unlocks the asset.

Remarks

What a lock does depends on the version control system and server setup. It might prevent other people from editing the asset at all, or only prevent them from submitting it to the server.