Example #1
0
        /// <summary>
        /// 分析引用关系
        /// </summary>
        public void Analyze()
        {
            if (_isAnalyzed)
            {
                return;
            }
            _isAnalyzed = true;

            Object[] deps = EditorUtility.CollectDependencies(new Object[] { asset });

            List <Object> depList = new List <Object>();

            for (int i = 0; i < deps.Length; i++)
            {
                Object o = deps[i];

                //不包含脚本对象
                //不包含LightingDataAsset对象
                if (o is MonoScript || o is LightingDataAsset)
                {
                    continue;
                }

                //不包含builtin对象
                string path = AssetDatabase.GetAssetPath(o);
                if (path.StartsWith("Resources"))
                {
                    continue;
                }

                depList.Add(o);
            }
            deps = depList.ToArray();

            var res = from s in deps
                      let obj = AssetDatabase.GetAssetPath(s)
                                select obj;
            var paths = res.Distinct().ToArray();

            for (int i = 0; i < paths.Length; i++)
            {
                if (File.Exists(paths[i]) == false)
                {
                    // Debug.Log("invalid:" + paths[i]);
                    continue;
                }
                FileInfo    fi     = new FileInfo(paths[i]);
                AssetTarget target = AssetBundleUtils.Load(fi);
                if (target == null)
                {
                    continue;
                }

                this.AddDependParent(target);

                target.Analyze();
            }
        }
Example #2
0
 public void AddRootTargets(DirectoryInfo bundleDir, string[] partterns = null, SearchOption searchOption = SearchOption.AllDirectories)
 {
     if (partterns == null)
     {
         partterns = new string[] { "*.*" }
     }
     ;
     for (int i = 0; i < partterns.Length; i++)
     {
         FileInfo[] prefabs = bundleDir.GetFiles(partterns[i], searchOption);
         foreach (FileInfo file in prefabs)
         {
             if (file.Extension.Contains("meta"))
             {
                 continue;
             }
             AssetTarget target = AssetBundleUtils.Load(file);
             target.exportType = AssetBundleExportType.Root;
         }
     }
 }