コード例 #1
0
        internal static bool IsOpenForEdit(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.IsOpenForEdit(assetPath, out message, statusOptions))
            {
                return(false);
            }
            if (!IsOpenForEditViaScriptCallbacks(assetPath, ref message))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        internal static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions)
        {
            message = "";
            if (String.IsNullOrEmpty(assetPath))
            {
                return(true); // assetPath can be empty in some cases where Unity is checking for stuff in Library folder
            }
            bool rootFolder, readOnly;
            bool validPath = AssetDatabase.GetAssetFolderInfo(assetPath, out rootFolder, out readOnly);

            if (validPath && readOnly)
            {
                return(false);
            }

            bool finalResult = AssetModificationHook.IsOpenForEdit(assetPath, out message, statusOptions);

            foreach (var method in GetIsOpenForEditMethods())
            {
                object[] args = { assetPath, message };
                if (!((bool)method.Invoke(null, args)))
                {
                    message = args[1] as string;
                    return(false);
                }
            }

            return(finalResult);
        }
コード例 #3
0
        internal static bool IsOpenForEdit(string assetPath, out string message)
        {
            message = string.Empty;
            if (string.IsNullOrEmpty(assetPath))
            {
                return(true);
            }
            bool result = AssetModificationHook.IsOpenForEdit(assetPath, out message);

            MethodInfo[] array = AssetModificationProcessorInternal.GetIsOpenForEditMethods();
            for (int i = 0; i < array.Length; i++)
            {
                MethodInfo methodInfo = array[i];
                object[]   array2     = new object[]
                {
                    assetPath,
                    message
                };
                if (!(bool)methodInfo.Invoke(null, array2))
                {
                    message = (array2[1] as string);
                    return(false);
                }
            }
            return(result);
        }
コード例 #4
0
        internal static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions)
        {
            message = "";
            bool result;

            if (string.IsNullOrEmpty(assetPath))
            {
                result = true;
            }
            else
            {
                bool         flag  = AssetModificationHook.IsOpenForEdit(assetPath, out message, statusOptions);
                MethodInfo[] array = AssetModificationProcessorInternal.GetIsOpenForEditMethods();
                for (int i = 0; i < array.Length; i++)
                {
                    MethodInfo methodInfo = array[i];
                    object[]   array2     = new object[]
                    {
                        assetPath,
                        message
                    };
                    if (!(bool)methodInfo.Invoke(null, array2))
                    {
                        message = (array2[1] as string);
                        result  = false;
                        return(result);
                    }
                }
                result = flag;
            }
            return(result);
        }
コード例 #5
0
        internal static void IsOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible)
        {
            outNotEditablePaths.Clear();
            if (assetOrMetaFilePaths == null || assetOrMetaFilePaths.Length == 0)
            {
                return;
            }

            var queryList = new List <string>();

            foreach (var path in assetOrMetaFilePaths)
            {
                if (string.IsNullOrEmpty(path))
                {
                    continue; // treat empty/null paths as editable (might be under Library folders etc.)
                }
                var editability = GetPathEditability(path);
                if (editability == Editability.Always)
                {
                    continue;
                }
                if (editability == Editability.Never)
                {
                    outNotEditablePaths.Add(path);
                    continue;
                }
                queryList.Add(path);
            }

            // check with VCS
            AssetModificationHook.IsOpenForEdit(queryList, outNotEditablePaths, statusQueryOptions);

            // check with possible script callbacks
            var scriptCallbacks = GetIsOpenForEditMethods();

            if (scriptCallbacks != null && scriptCallbacks.Length > 0)
            {
                var stillEditable = assetOrMetaFilePaths.Except(outNotEditablePaths).Where(f => !string.IsNullOrEmpty(f));
                var message       = string.Empty;
                foreach (var path in stillEditable)
                {
                    if (!IsOpenForEditViaScriptCallbacks(path, ref message))
                    {
                        outNotEditablePaths.Add(path);
                    }
                }
            }
        }
コード例 #6
0
        internal static bool IsOpenForEdit(string assetPath, out string message)
        {
            message = string.Empty;
            if (string.IsNullOrEmpty(assetPath))
            {
                return(true);
            }
            bool flag = AssetModificationHook.IsOpenForEdit(assetPath, out message);

            foreach (MethodInfo info in GetIsOpenForEditMethods())
            {
                object[] parameters = new object[] { assetPath, message };
                if (!((bool)info.Invoke(null, parameters)))
                {
                    message = parameters[1] as string;
                    return(false);
                }
            }
            return(flag);
        }
コード例 #7
0
        internal static bool IsOpenForEdit(string assetPath, out string message)
        {
            message = string.Empty;
            if (string.IsNullOrEmpty(assetPath))
            {
                return(true);
            }
            bool flag = AssetModificationHook.IsOpenForEdit(assetPath, out message);

            foreach (MethodInfo openForEditMethod in AssetModificationProcessorInternal.GetIsOpenForEditMethods())
            {
                object[] parameters = new object[2]
                {
                    (object)assetPath,
                    (object)message
                };
                if (!(bool)openForEditMethod.Invoke((object)null, parameters))
                {
                    message = parameters[1] as string;
                    return(false);
                }
            }
            return(flag);
        }