此类提供对版本控制 API 的访问。
请注意,版本控制窗口会在每个版本控制操作之后刷新。这意味着,在多个资源中循环并对每个资源执行单独操作(例如签出)的速度慢于传递包含所有资源的 AssetList 并对它执行一次版本控制操作。
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(); } }
另请注意,提供程序操作仅执行 VCS 命令,而不自动刷新版本控制窗口。若要更新此窗口,请使用 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 | 获取当前正在执行的任务。 |
enabled | 如果已启用版本控制提供程序并找到有效的 Unity Pro 许可证,则返回 true。 |
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 | 如果已正确选择和配置版本控制插件,则返回 true。 |
offlineReason | 返回版本控制提供程序的离线原因(如果离线)。 |
onlineState | 返回版本控制提供程序的在线状态。 |
preCheckoutCallback | 在版本控制签出操作之前要调用的用户提供的回调。 |
preSubmitCallback | 在版本控制提交操作之前要调用的用户提供的回调。 |
requiresNetwork | 如果当前选择的版本控制插件执行任何操作时需要网络连接,则为 true。 |
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 | 给定仅包含变更集 ID 的变更集,此方法将启动用于查询变更集相关描述的任务。 |
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 | 此方法将使所有资源的缓存状态信息无效。 |
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 | 启动一个任务,用于显示给定资源与其最新版本之间的差异。 |
DiffIsValid | Returns true if starting a Diff task is a valid operation for at least one asset in the given AssetList. |
GetActiveConfigFields | 返回当前活动版本控制插件的配置字段。 |
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 | 给定传入的变更集,此方法将启动一个任务,用于在版本控制服务器中查询其资源是否属于变更集的一部分。 |
IsOpenForEdit | 如果资源可以进行编辑,则返回 true。 |
Lock | 尝试锁定资源,以便以独占方式编辑资源。 |
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 | 使用版本控制插件将资源从一个路径移动到另一个路径。 |
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 | 如果提交资源是有效操作,则返回 true。 |
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 | 在版本控制签出之前要调用的用户提供的回调的委托。 |
PreSubmitCallback | 在版本控制提交之前要调用的用户提供的回调的委托。 |