path | Specifies the path to a file relative to the project root. |
bool
true
if Unity successfully made the file editable in the version control system. Otherwise, returns false
.
Makes a file open for editing in version control.
Your version control system may be configured to only allow a single person at a time to
edit certain types of files in order to avoid merge conflicts that arise when multiple people edit the same file.
In this case, you must 'open' that file for editing (also known as 'checking out') to ensure that you have permission
to edit the file at this time. Use this function to make a file 'open for editing' in a version control system that supports it.
File paths that are outside of Unity project folder, or not under version controlled folders (for example, "Library" or "Temp"),
are always considered editable. MakeEditable
returns true
for them, and otherwise does nothing.
File paths that refer to non-local Package folders are always considered to be non-editable. MakeEditable
returns false
for them.
When no version control system is active, then file paths inside the project are all considered already editable. MakeEditable
returns true
and otherwise does nothing.
When using a version control system, for example Perforce Helix, MakeEditable
triggers a "Checkout" operation
on the files, unless they are already editable. For files that were not added to version control yet, MakeEditable/
will add them to version control.
If you set up a pre-checkout callback, Unity calls it as part of MakeEditable
.
See PreCheckoutCallback for more details.
using UnityEngine; using UnityEditor;
public class ExampleScript : MonoBehaviour { [MenuItem("Example/Checkout Selected Asset")] public static void MenuExample() { var path = AssetDatabase.GetAssetPath(Selection.activeObject); var ok = AssetDatabase.MakeEditable(path); if (!ok) Debug.LogError($"Could not make {path} editable"); } }
See Also: AssetDatabase.IsOpenForEdit.
paths | Specifies an array of file paths relative to the project root. |
prompt | Dialog prompt to show to the user, if a version control operation needs to be done. If null (default), no prompt is shown. |
outNotEditablePaths | Output list of file paths that could not be made editable. |
bool
true
if Unity successfully made all files editable in the version control system.
Makes a list of files open for editing in version control.
A multi-file variant of MakeEditable
, that can also optionally show a prompt
to the user if a Checkout/Add version control operation needs to be done. If the user cancels the dialog,
Unity does not make the files editable. If the Unity Editor is operating in batch mode, Unity does not
show a dialog and acts as if the user accepted the dialog prompt.
If you pass an outNotEditablePaths
List, this function fills it with file paths that Unity could make editable.
using System.Linq; using UnityEngine; using UnityEditor;
public class ExampleScript : MonoBehaviour { [MenuItem("Example/Checkout Selected Assets")] public static void MenuExample() { var guids = Selection.assetGUIDs; var paths = guids.Select(AssetDatabase.GUIDToAssetPath).ToArray(); var ok = AssetDatabase.MakeEditable(paths, "These files need to be checked out"); if (!ok) Debug.LogError("Could not make some files editable"); } }
See Also: AssetDatabase.IsOpenForEdit.
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.