Documentation

Unity Engine

Unity Engine

Add

Starts a task that adds a list of assets to version control.
Read time 2 minutesLast updated 11 days ago

Definition

Add(AssetList, bool)

Starts a task that adds a list of assets to version control.
public static Task Add(AssetList assets, bool recursive)

Parameters

assets

The list of assets to add to version control.

recursive

Set to true to also add the contents of any folders, recursively. Set to false to add only the specified items.

Returns

Type

Description

TaskThe task that adds the assets to version control.

Remarks

If you select a version control integration in the project settings, Unity adds new files to version control by default. You can disable the Automatic add setting to prevent this. Use this method to add files to version control from a script when automatic adding is disabled. For more information, refer to Version control integration.

Examples

using System.Collections.Generic;using UnityEditor;using UnityEditor.VersionControl;using UnityEngine;public class EditorScript : MonoBehaviour{ [MenuItem("Version Control/Add")] static void ExampleAdd() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/ExampleAsset.cs")); Task t = Provider.Add(assets, recursive: false); t.Wait(); }}

Add(Asset, bool)

Starts a task that adds a single asset to version control.
public static Task Add(Asset asset, bool recursive)

Parameters

asset

The asset to add to version control.

recursive

Set to true to also add the contents of any folders, recursively. Set to false to add only the specified items.

Returns

Type

Description

TaskThe task that adds the asset to version control.

Remarks

If you select a version control integration in the project settings, Unity adds new files to version control by default. You can disable the Automatic add setting to prevent this. Use this method to add files to version control from a script when automatic adding is disabled. For more information, refer to Version control integration.