Пример #1
0
        /// <summary>
        ///     Returns true if the asset at the given path should be ignored.
        /// </summary>
        /// <returns><c>true</c>, if path should be ignored, <c>false</c> otherwise.</returns>
        /// <param name="path">Path.</param>
        private static bool IgnorePath(string path)
        {
            if (!MaintenanceUtils.InAssetsDir(path))
            {
                return(true);
            }

            string ext = Path.GetExtension(path);

            if (Array.Exists(s_ExtIgnore, element => element == ext))
            {
                return(true);
            }

            for (int index = 0; index < s_DirIgnore.Length; index++)
            {
                string dirName = s_DirIgnore[index];
                if (MaintenanceUtils.ContainsDirName(path, dirName))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        ///     Gets the dependencies.
        /// </summary>
        /// <returns>The dependencies.</returns>
        /// <param name="path">Path.</param>
        private static void GetDependencies(string path, List <string> output)
        {
            if (Path.GetExtension(path) == ".unity")
            {
                GetSceneDependencies(path, output);
                return;
            }

            string guid = AssetDatabase.AssetPathToGUID(path);

            Object[] assets       = AssetDatabase.LoadAllAssetsAtPath(path);
            Object[] dependencies = EditorUtility.CollectDependencies(assets);

            for (int dependencyIndex = 0; dependencyIndex < dependencies.Length; dependencyIndex++)
            {
                Object dependency     = dependencies[dependencyIndex];
                string dependencyPath = AssetDatabase.GetAssetPath(dependency);

                if (!MaintenanceUtils.InAssetsDir(dependencyPath))
                {
                    continue;
                }

                string dependencyGuid = AssetDatabase.AssetPathToGUID(dependencyPath);
                if (dependencyGuid == guid)
                {
                    continue;
                }

                output.Add(dependencyGuid);
            }
        }
Пример #3
0
        /// <summary>
        ///     We can't load the scene to collect dependencies, so let's get dirty and
        ///     parse the file for GUIDs.
        /// </summary>
        /// <param name="path">Path.</param>
        /// <param name="output">Output.</param>
        private static void GetSceneDependencies(string path, List <string> output)
        {
            using (StreamReader reader = new StreamReader(path))
            {
                while (reader.Peek() >= 0)
                {
                    string line = reader.ReadLine();
                    if (!line.Contains(GUID_PREFIX))
                    {
                        continue;
                    }

                    string guidPart = line.Split(',')[1];

                    string guid      = StringUtils.RemoveSubstring(guidPart, GUID_PREFIX).Trim();
                    string assetPath = AssetDatabase.GUIDToAssetPath(guid);

                    if (string.IsNullOrEmpty(assetPath))
                    {
                        continue;
                    }

                    if (!MaintenanceUtils.InAssetsDir(assetPath))
                    {
                        continue;
                    }

                    output.Add(guid);
                }
            }
        }
Пример #4
0
        /// <summary>
        ///     Caches the dependencies.
        /// </summary>
        private static void CacheDependencies()
        {
            s_CachedGuidDependencies.Clear();

            string[] paths = AssetDatabase.GetAllAssetPaths();

            for (int index = 0; index < paths.Length; index++)
            {
                string path = paths[index];
                if (!File.Exists(path))
                {
                    continue;
                }

                if (MaintenanceUtils.IsDirectory(path))
                {
                    continue;
                }

                if (!MaintenanceUtils.InAssetsDir(path))
                {
                    continue;
                }

                List <string> dependencies = new List <string>();
                GetDependencies(path, dependencies);
                string guid = AssetDatabase.AssetPathToGUID(path);

                s_CachedGuidDependencies[guid] = dependencies;

                UpdateProgressBar("Caching dependencies:", index + 1);
            }
        }