Add
Starts a task that adds a list of assets to version control.
読み終わるまでの所要時間 2 分最終更新 19日前
Definition
- Type: Method
- Namespace: UnityEditor.VersionControl
- Assembly: UnityEditor.CoreModule
Add(AssetList, bool)
Starts a task that adds a list of assets to version control.
public static Task Add(AssetList assets, bool recursive)
Parameters
Returns
Type | Description |
|---|---|
| Task | The 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
Returns
Type | Description |
|---|---|
| Task | The 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.