Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

AssetDatabase.CanOpenForEdit

Suggest a change

Success!

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.

Close

Submission failed

For 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.

Close

Cancel

Declaration

public static bool CanOpenForEdit(Object assetObject, StatusQueryOptions statusOptions = StatusQueryOptions.UseCachedIfPossible);

Parameters

Parameter Description
assetObject The asset object to check.
statusOptions How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.

Returns

bool True if the version control system considers the asset available for editing. Otherwise, false.

Description

Checks whether an asset object can be opened for editing in version control.

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.


Declaration

public static bool CanOpenForEdit(string assetOrMetaFilePath, StatusQueryOptions statusOptions = StatusQueryOptions.UseCachedIfPossible);

Parameters

Parameter Description
assetOrMetaFilePath The project-relative path of the asset file or its .meta file.
statusOptions How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.

Returns

void True if the version control system considers the asset available for editing. Otherwise, false.

Description

Checks whether the asset at a path can be opened for editing in version control.

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.


Declaration

public static bool CanOpenForEdit(Object assetObject, out string message, StatusQueryOptions statusOptions = StatusQueryOptions.UseCachedIfPossible);

Parameters

Parameter Description
assetObject The asset object to check.
message When the method returns, contains the reason why the asset isn't available for editing, if there is one.
statusOptions How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.

Returns

void True if the version control system considers the asset available for editing. Otherwise, false.

Description

Checks whether an asset object can be opened for editing in version control and gets the reason if it isn't.

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.


Declaration

public static bool CanOpenForEdit(string assetOrMetaFilePath, out string message, StatusQueryOptions statusOptions = StatusQueryOptions.UseCachedIfPossible);

Parameters

Parameter Description
assetOrMetaFilePath The project-relative path of the asset file or its .meta file.
message When the method returns, contains the reason why the asset isn't available for editing, if there is one.
statusOptions How to query the version control system. These options affect the speed and accuracy of the query. The default value is StatusQueryOptions.UseCachedIfPossible.

Returns

void True if the version control system considers the asset available for editing. Otherwise, false.

Description

Checks whether the asset at a path can be opened for editing in version control and gets the reason if it isn't.

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.


Declaration

public static void CanOpenForEdit(string[] assetOrMetaFilePaths, List<string> outNotEditablePaths, StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible);

Parameters

Parameter Description
assetOrMetaFilePaths Paths to Assets or their .meta files, relative to the project folder.
outNotEditablePaths Destination list of non-editable Asset paths.
statusQueryOptions Specifies how Unity should query the version control system. The default value is StatusQueryOptions.UseCachedIfPossible.

Description

Query which of the provided Asset files can be opened for editing in version control and are not remotely locked or otherwise unavailable.

This variant of the CanOpenForEdit function can query multiple Asset paths at once. It writes paths for Assets that are not 'available for edit' into the outNotEditablePaths list.