Ejemplo n.º 1
0
        public static AssetDependencyData GetDependencyData(string assetPath, string[] ignoreExt = null)
        {
            AllAssetDependencyData allAssetData = GetOrCreateAllAssetData();
            AssetDependencyData    assetData    = allAssetData.GetData(assetPath);

            if (assetData == null)
            {
                assetData = new AssetDependencyData()
                {
                    assetPath       = assetPath,
                    directlyDepends = AssetDatabaseUtility.GetDirectlyDependencies(assetPath, ignoreExt),
                    allDepends      = AssetDatabaseUtility.GetDependencies(assetPath, ignoreExt),
                };
                allAssetData.AddData(assetData);

                EditorUtility.SetDirty(allAssetData);
            }
            return(assetData);
        }
Ejemplo n.º 2
0
        public static void FindAllAssetData(Action <string, string, float> progressAction = null)
        {
            AllAssetDependencyData data = GetOrCreateAllAssetData();

            data.Clear();

            List <string> assetPaths = new List <string>();

            string assetDirectory = PathUtility.GetDiskPath("Assets");

            string[] allDirectoriesInAsset = Directory.GetDirectories(assetDirectory, "*", SearchOption.AllDirectories);
            for (int i = 0; i < allDirectoriesInAsset.Length; ++i)
            {
                string dir = allDirectoriesInAsset[i].Replace("\\", "/");
                if (dir.IndexOf("/Plugins") >= 0 || dir.IndexOf("/StreamingAssets") >= 0 || dir.IndexOf("/Editor") >= 0)
                {
                    continue;
                }

                progressAction?.Invoke("Search files", $"Search:{dir}", i / (float)allDirectoriesInAsset.Length);

                (from file in Directory.GetFiles(dir, "*.*", SearchOption.TopDirectoryOnly)
                 where Path.GetExtension(file).ToLower() != ".meta"
                 select PathUtility.GetAssetPath(file)
                ).ToList().ForEach((f) => { assetPaths.Add(f); });
            }

            if (assetPaths.Count > 0)
            {
                for (int i = 0; i < assetPaths.Count; ++i)
                {
                    progressAction?.Invoke("Get Dependency", $"{assetPaths[i]}", i / (float)assetPaths.Count);
                    allAssetData.AddData(GetDependencyData(assetPaths[i]));
                }
            }
            EditorUtility.SetDirty(allAssetData);
        }