Пример #1
0
        static bool GetOpenForEdit(bool canOpenForEditVariant, string assetPath, out string message, StatusQueryOptions statusOptions)
        {
            message = string.Empty;
            if (string.IsNullOrEmpty(assetPath))
            {
                return(true); // treat empty/null paths as editable (might be under Library folders etc.)
            }
            var editability = GetPathEditability(assetPath);

            if (editability == Editability.Always)
            {
                return(true);
            }
            if (editability == Editability.Never)
            {
                return(false);
            }

            if (!AssetModificationHook.GetOpenForEdit(canOpenForEditVariant, assetPath, out message, statusOptions))
            {
                return(false);
            }

            return(GetOpenForEditViaScriptCallbacks(canOpenForEditVariant, new[] { assetPath }, new List <string>(), out message, statusOptions));
        }
Пример #2
0
        internal static bool CanOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, StatusQueryOptions statusQueryOptions)
        {
            outNotEditablePaths.Clear();
            if (assetOrMetaFilePaths == null || assetOrMetaFilePaths.Length == 0)
            {
                return(true);
            }

            var queryList = GetQueryList(assetOrMetaFilePaths, outNotEditablePaths);

            if (queryList.Count == 0)
            {
                return(outNotEditablePaths.Count == 0);
            }

            // Get a list of paths that are not open for edit.
            var notOpenForEditPaths = new List <string>();

            AssetModificationHook.GetOpenForEdit(false, queryList, notOpenForEditPaths, statusQueryOptions);
            GetOpenForEditViaScriptCallbacks(false, queryList.ToArray(), notOpenForEditPaths, out var message, statusQueryOptions);

            if (notOpenForEditPaths.Count == 0)
            {
                return(outNotEditablePaths.Count == 0);
            }

            // Status has just been updated so there's no need to force update again.
            if (statusQueryOptions == StatusQueryOptions.ForceUpdate)
            {
                statusQueryOptions = StatusQueryOptions.UseCachedIfPossible;
            }

            // Check paths that are not open for edit.
            if (!AssetModificationHook.GetOpenForEdit(true, notOpenForEditPaths, outNotEditablePaths, statusQueryOptions))
            {
                return(false);
            }

            return(GetOpenForEditViaScriptCallbacks(true, notOpenForEditPaths.ToArray(), outNotEditablePaths, out message, statusQueryOptions));
        }
Пример #3
0
        internal static bool IsOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, StatusQueryOptions statusQueryOptions)
        {
            outNotEditablePaths.Clear();
            if (assetOrMetaFilePaths == null || assetOrMetaFilePaths.Length == 0)
            {
                return(true);
            }

            var queryList = GetQueryList(assetOrMetaFilePaths, outNotEditablePaths);

            if (queryList.Count == 0)
            {
                return(outNotEditablePaths.Count == 0);
            }

            // check with VCS
            if (!AssetModificationHook.GetOpenForEdit(false, queryList, outNotEditablePaths, statusQueryOptions))
            {
                return(false);
            }

            // check with possible script callbacks
            return(GetOpenForEditViaScriptCallbacks(false, queryList.ToArray(), outNotEditablePaths, out var message, statusQueryOptions));
        }