class in UnityEditor.VersionControl
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseThis class provides access to the version control API.
Note that the Version Control window is refreshed after every version control operation. This means that looping through multiple assets and doing an individual operation on each (i.e. Checkout) will be slower than passing an AssetList containing all of the assets and performing a version control operation on it once.
using System.Collections.Generic; using UnityEditor; using UnityEditor.VersionControl; using UnityEngine;
public class EditorScript : MonoBehaviour { [MenuItem("VC/Checkout")] public static void TestCheckout() { AssetList assets = new AssetList(); assets.Add(new Asset("Assets/"));
Task t = Provider.Checkout(assets, CheckoutMode.Both); t.Wait(); } }
Also note that Provider operations just execute the VCS commands, and do not automatically refresh the Version Control window. To update this window, use Task.SetCompletionAction.
using System.Collections.Generic; using UnityEditor; using UnityEditor.VersionControl; using UnityEngine;
public class EditorScript : MonoBehaviour { [MenuItem("VC/ChangeSetMove")] static void ChangeSetMove() { AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByPath("Assets/testMaterial.mat")); Task task = Provider.ChangeSetMove(assets, "ChangeSetID"); task.SetCompletionAction(CompletionAction.UpdatePendingWindow); } }
activeTask | Gets the currently executing task. |
enabled | Returns true if the version control provider is enabled and a valid Unity Pro License was found. |
hasCheckoutSupport | This is true if the currently selected version control plugin supports the Checkout method. |
hasLockingSupport | This is true if the currently selected version control plugin supports the Lock and Unlock methods. |
isActive | Returns true if a version control plugin has been selected and configured correctly. |
offlineReason | Returns the reason for the version control provider being offline (if it is offline). |
onlineState | Returns the OnlineState of the version control provider. |
preCheckoutCallback | User-supplied callback to be called before Version Control check out operation. |
preSubmitCallback | User-supplied callback to be called before Version Control Submit operation. |
requiresNetwork | This is true if a network connection is required by the currently selected version control plugin to perform any action. |
Add | Allows you to add files to version control via script. |
AddIsValid | Given a list of assets this function returns true if Provider.Add is a valid task to perform on at least one of the assets in the list. |
ChangeSetDescription | Given a changeset only containing the changeset ID, this will start a task for quering the description of the changeset. |
ChangeSetMove | Move an Asset or a list of Assets from their current changeset to a new changeset. |
ChangeSets | Gets a list of pending changesets owned by the current user. |
ChangeSetStatus | Retrieves a list of assets belonging to a changeset. |
Checkout | Checkout an asset or a list of assets from the version control system. |
CheckoutIsValid | Given an asset or a list of assets this function returns true if Provider.Checkout is a valid task to perform on at least one of the given assets. |
ClearCache | This will invalidate the cached state information for all assets. |
Delete | Starts a task to delete an Asset or a list of Assets from the disk and from the version control system. |
DeleteChangeSets | Starts a task that will attempt to delete the given changesets. |
DeleteChangeSetsIsValid | Tests if deleting the given changesets is a valid task to perform. |
DiffHead | Starts a task for showing a diff of the given assest versus their head revision. |
DiffIsValid | Returns true if starting a Diff task is a valid operation for at least one asset in the given AssetList. |
GetActiveConfigFields | Returns the configuration fields for the currently active version control plugin. |
GetActivePlugin | Gets the current, user selected verson control Plugin. |
GetAssetByGUID | Returns version control information about an asset from a given GUID. |
GetAssetByPath | Returns the version control information about an asset. Can be used with "AssetList.Add" to add assets to a list for further version control actions. |
GetAssetListFromSelection | Returns the version control information about the currently selected Assets. |
GetLatest | Start a task for getting the latest version of an out of sync asset from the version control server. |
GetLatestIsValid | The task tests the given asset list and returns true if Provider.GetLatest is valid operation for one or more assets. |
Incoming | Starts a task that queries the version control server for incoming changes. |
IncomingChangeSetAssets | Given an incoming changeset this will start a task to query the version control server for which assets are part of the changeset. |
IsOpenForEdit | Returns true if an asset can be edited. |
Lock | Attempt to lock an asset for exclusive editing. |
LockIsValid | Returns true if the Provider.Lock task can be executed on one or more assets from the given asset list. |
Merge | Initiates a merge task to handle the merging of conflicting Assets. This invokes a merge tool, which you can set in the External Tools section of the Preferences window, on the conflicting Assets. When the merge task finishes, the AssetList only contains the Assets that the tool could merge. |
Move | Uses the version control plugin to move an asset from one path to another. |
Resolve | Starts a task that will resolve the conflicting assets in version control. |
ResolveIsValid | Tests if any of the assets in the list have the conflicted state and can be resolved. |
Revert | Reverts the specified assets by undoing any changes done since the last time you synced. |
RevertIsValid | Returns true if Provider.Revert is a valid task to perform on at least one of the given assets in the list. |
Status | Starts a task that will fetch the most recent status about the asset or assets from the revision control system. |
Submit | Starts a task that submits the assets to version control. |
SubmitIsValid | Returns true if submitting the assets is a valid operation. |
UnlockIsValid | Returns true if unlocking the assets is a valid operation. |
UpdateSettings | Starts a task that sends the version control settings to the version control system. |
PreCheckoutCallback | Delegate for a user-supplied callback to be called before Version Control Checkout. |
PreSubmitCallback | Delegate for a user-supplied callback to be called before Version Control Submit. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.