CanOpenForEdit
Query which of the provided Asset files can be opened for editing in version control and are not remotely locked or otherwise unavailable.
Read time 4 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
CanOpenForEdit(string[], List<string>, StatusQueryOptions)
Query which of the provided Asset files can be opened for editing in version control and are not remotely locked or otherwise unavailable.
public static void CanOpenForEdit(string[] assetOrMetaFilePaths, List<string> outNotEditablePaths, StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible)
Parameters
Paths to Assets or their .meta files, relative to the project folder.
Destination list of non-editable Asset paths.
Specifies how Unity should query the version control system. The default value is StatusQueryOptions.UseCachedIfPossible.
Remarks
This variant of the function can query multiple Asset paths at once. It writes paths for Assets that are not 'available for edit' into the list.
CanOpenForEditoutNotEditablePathsCanOpenForEdit(Object, StatusQueryOptions)
Checks whether an asset object can be opened for editing in version control.
public static bool CanOpenForEdit(Object assetObject, StatusQueryOptions statusOptions)
Parameters
The asset object to check.
How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.
Returns
Type | Description |
|---|---|
| bool | True if the version control system considers the asset available for editing. Otherwise, false. |
Remarks
Use this method before you modify an asset, to check whether the version control system lets you edit it. An asset isn't available if another user has locked it exclusively, or if it's otherwise unavailable. For details on how version control systems decide this, refer to AssetDatabase.IsOpenForEdit. To make an asset editable, use AssetDatabase.MakeEditable.
CanOpenForEdit(string, StatusQueryOptions)
Checks whether the asset at a path can be opened for editing in version control.
public static bool CanOpenForEdit(string assetOrMetaFilePath, StatusQueryOptions statusOptions)
Parameters
The project-relative path of the asset file or its .meta file.
How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.
Returns
Type | Description |
|---|---|
| bool | True if the version control system considers the asset available for editing. Otherwise, false. |
Remarks
Use this method before you modify an asset, to check whether the version control system lets you edit it. An asset isn't available if another user has locked it exclusively, or if it's otherwise unavailable. For details on how version control systems decide this, refer to AssetDatabase.IsOpenForEdit. To make an asset editable, use AssetDatabase.MakeEditable.
CanOpenForEdit(Object, string, StatusQueryOptions)
Checks whether an asset object can be opened for editing in version control and gets the reason if it isn't.
public static bool CanOpenForEdit(Object assetObject, out string message, StatusQueryOptions statusOptions)
Parameters
The asset object to check.
When the method returns, contains the reason why the asset isn't available for editing, if there is one.
How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.
Returns
Type | Description |
|---|---|
| bool | True if the version control system considers the asset available for editing. Otherwise, false. |
Remarks
Use this method before you modify an asset, to check whether the version control system lets you edit it. An asset isn't available if another user has locked it exclusively, or if it's otherwise unavailable. For details on how version control systems decide this, refer to AssetDatabase.IsOpenForEdit. To make an asset editable, use AssetDatabase.MakeEditable.
CanOpenForEdit(string, string, StatusQueryOptions)
Checks whether the asset at a path can be opened for editing in version control and gets the reason if it isn't.
public static bool CanOpenForEdit(string assetOrMetaFilePath, out string message, StatusQueryOptions statusOptions)
Parameters
The project-relative path of the asset file or its .meta file.
When the method returns, contains the reason why the asset isn't available for editing, if there is one.
How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.
Returns
Type | Description |
|---|---|
| bool | True if the version control system considers the asset available for editing. Otherwise, false. |
Remarks
Use this method before you modify an asset, to check whether the version control system lets you edit it. An asset isn't available if another user has locked it exclusively, or if it's otherwise unavailable. For details on how version control systems decide this, refer to AssetDatabase.IsOpenForEdit. To make an asset editable, use AssetDatabase.MakeEditable.