public string[] GetDirectDependencies(string assetPath)
        {
            string assetBundleName = GetAssetBundleNameByAssetPath(assetPath);

            if (m_cManifest != null)
            {
                string[] paths = m_cManifest.GetDirectDependencies(assetBundleName);
                return(paths);
            }
            return(new string[] { });
        }
Exemple #2
0
        /// <summary> アセットバンドルの参照情報を書き込み </summary>
        public static void SetDependencies(AssetInfoManifest assetInfoManifest, AssetBundleManifest assetBundleManifest)
        {
            var assetInfos = assetInfoManifest.GetAssetInfos().Where(x => x.IsAssetBundle).ToArray();

            foreach (var assetInfo in assetInfos)
            {
                var dependencies = assetBundleManifest.GetDirectDependencies(assetInfo.AssetBundle.AssetBundleName);

                assetInfo.AssetBundle.SetDependencies(dependencies);
            }
        }
Exemple #3
0
 public static string[] TryGetDirectDependencies(this AssetBundleManifest self, string abName)
 {
     if (!self)
     {
         return(new string[0]);
     }
     return(self
            .GetDirectDependencies(abName)
            .OrderBy(c => c)
            .ToArray());;
 }
Exemple #4
0
        public string[] GetDirectDependencies(string bundleName)
        {
            if (ResMgr.IsSimulationModeLogic)
            {
                return(AssetBundleDatas
                       .Find(data => data.Name == bundleName)
                       .DenpendnecyBundleNames);
            }

            return(mManifest.GetDirectDependencies(bundleName));
        }
Exemple #5
0
    private static AssetBundleHeader.DepInfo[] CalcNormalDeps(string assetBundleName, Object asset, AssetBundleManifest manifest)
    {
        string[] depBundleNames = manifest.GetDirectDependencies(assetBundleName);
        var      deps           = new AssetBundleHeader.DepInfo[depBundleNames.Length];

        for (int n = 0; n < depBundleNames.Length; n++)
        {
            deps[n].name = "";
            deps[n].path = depBundleNames[n] + ".u3dext";
        }
        return(deps);
    }
    public static void LoadBundleDependencies()
    {
        string              manifestFilePath    = ResourceUtil.bundleRootPath + "AssetBundles";
        AssetBundle         assetBundle         = AssetBundle.LoadFromFile(manifestFilePath);
        AssetBundleManifest assetBundleManifest = assetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

        string[] allBundles = assetBundleManifest.GetAllAssetBundles();
        foreach (string bundleName in allBundles)
        {
            string[] dependencies = assetBundleManifest.GetDirectDependencies(bundleName);
            AddDependencies(bundleName, dependencies);
        }
    }
Exemple #7
0
 void ShowLevelDep(string rootABName)
 {
     print("root------>" + rootABName);
     string[] dependencies = abm.GetDirectDependencies(rootABName);
     if (dependencies.Length == 0)
     {
         return;
     }
     for (int i = 0; i < dependencies.Length; i++)
     {
         ShowLevelDep(dependencies[i]);
     }
 }
Exemple #8
0
        /// <summary>
        /// 内部加载bundle
        /// </summary>
        /// <param name="url">asset路径</param>
        /// <param name="async">是否异步</param>
        /// <returns>bundle对象</returns>
        private ABundle LoadInternal(string url, bool async)
        {
            ABundle bundle;

            if (m_BundleDic.TryGetValue(url, out bundle))
            {
                if (bundle.reference == 0)
                {
                    m_NeedUnloadList.Remove(bundle);
                }

                //从缓存中取并引用+1
                bundle.AddReference();

                return(bundle);
            }

            //创建ab
            if (async)
            {
                bundle     = new BundleAsync();
                bundle.url = url;
                m_AsyncList.Add(bundle as ABundleAsync);
            }
            else
            {
                bundle     = new Bundle();
                bundle.url = url;
            }

            m_BundleDic.Add(url, bundle);

            //加载依赖
            string[] dependencies = m_AssetBundleManifest.GetDirectDependencies(url);
            if (dependencies.Length > 0)
            {
                bundle.dependencies = new ABundle[dependencies.Length];
                for (int i = 0; i < dependencies.Length; i++)
                {
                    string  dependencyUrl    = dependencies[i];
                    ABundle dependencyBundle = LoadInternal(dependencyUrl, async);
                    bundle.dependencies[i] = dependencyBundle;
                }
            }

            bundle.AddReference();

            bundle.Load();

            return(bundle);
        }
Exemple #9
0
        public static uint CreateStreamingFileManifest(AssetBundleManifest assetBundleManifest)
        {
            var allABs             = assetBundleManifest.GetAllAssetBundles();
            var bundlesWithVariant = assetBundleManifest.GetAllAssetBundlesWithVariant();

            var streamingManifest = ScriptableObject.CreateInstance(typeof(FileManifest)) as FileManifest;
            //读取 bundlesWithVariant
            var MyVariant = new string[bundlesWithVariant.Length];

            for (int i = 0; i < bundlesWithVariant.Length; i++)
            {
                var curSplit = bundlesWithVariant[i].Split('.');
                MyVariant[i] = bundlesWithVariant[i];
            }
            //读取abinfo
            List <ABInfo> allABInfos = new List <ABInfo>();

            foreach (var abs in allABs)
            {
                var abInfo       = new ABInfo(abs, 0, 0, 0);
                var dependencies = assetBundleManifest.GetDirectDependencies(abs);
                abInfo.dependencies = dependencies;
                allABInfos.Add(abInfo);
            }

            //fill data
            streamingManifest.allAbInfo = allABInfos;
            streamingManifest.allAssetBundlesWithVariant = bundlesWithVariant;
            streamingManifest.appNumVersion    = CodeVersion.APP_NUMBER;
            streamingManifest.newAppNumVersion = CodeVersion.APP_NUMBER;
            streamingManifest.version          = CodeVersion.APP_VERSION;

            //create asset
            string tmpPath = EditorUtils.GetAssetTmpPath();// Path.Combine(Application.dataPath, BuildScript.TmpPath);

            EditorUtils.CheckDirectory(tmpPath);
            var    crc32filename = CUtils.GetAssetName(Common.CRC32_FILELIST_NAME);
            string assetPath     = "Assets/" + EditorUtils.TmpPath + crc32filename + ".asset";

            AssetDatabase.CreateAsset(streamingManifest, assetPath);
            //build assetbundle
            string crc32outfilename = CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME);

            BuildScript.BuildABs(new string[] { assetPath }, null, crc32outfilename, DefaultBuildAssetBundleOptions);

            streamingManifest.WriteToFile("Assets/" + EditorUtils.TmpPath + "BuildStreamingAssetsManifest.txt");
            Debug.LogFormat("FileManifest  Path = {0}/{1};", CUtils.realStreamingAssetsPath, crc32outfilename);
            return(0);
        }
        public static bool LoaderConstructor(object __instance, string key, string rootPath, AssetBundleManifest manifest, GInterface251 bundleLock, ref string ___string_1, ref string ___string_0, ref Task ___task_0, ref GInterface251 ___ginterface251_0)
        {
            SetPropertyValue(__instance, key, "Key");
            ___string_1 = rootPath + key;
            ___string_0 = Path.GetFileNameWithoutExtension(key);
            if (manifest != null)
            {
                SetPropertyValue(__instance, manifest.GetDirectDependencies(key), "DependencyKeys");
            }
            SetPropertyValue(__instance, new GClass2166 <ELoadState>(ELoadState.Unloaded), "LoadState");
            ___task_0          = null;
            ___ginterface251_0 = bundleLock;

            return(false);
        }
Exemple #11
0
 public Object Load(string name)
 {
     if (assetBundleManifest == null)
     {
         Loadependent(Common.targetPlatform.ToString());
         assetBundleManifest = loadedAssetBundleDictionary[Common.targetPlatform.ToString()].LoadAsset("AssetBundleManifest") as AssetBundleManifest;
     }
     string[] dep = assetBundleManifest.GetDirectDependencies(name + ".assetbundle");
     for (int i = 0; i < dep.Length; i++)
     {
         Loadependent(dep[i]);
     }
     Loadependent(name);
     return(loadedAssetBundleDictionary[name].LoadAsset(name));
 }
Exemple #12
0
        /// <summary>
        /// 加载依赖
        /// </summary>
        /// <param name="assetBundleName"></param>
        /// <returns></returns>
        private IEnumerator _LoadDependenciesAsyc(string strABName)
        {
            //从manifest获取依赖包名称
            if (m_assetBundleManifest == null)
            {
                Debug.LogError("Manifest file has not been loaded");
                yield break;
            }

            string[] dependencies = m_assetBundleManifest.GetDirectDependencies(strABName);
            if (dependencies.Length == 0)
                yield break;

            //// 记录依赖
            //m_dictDependencies.Add(assetBundleName, dependencies);

            // 异步加载依赖包
            for (int i = 0; i < dependencies.Length; i++)
            {
                Coroutine routine = StartCoroutine(_LoadAssetBundleAsyc(dependencies[i]));
                m_listCoroutine.Add(routine);
                yield return routine;
            }
        }
        /// <summary>
        /// 获取资源包列表
        /// </summary>
        private List <PatchBundle> GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters,
                                                     TaskGetBuildMap.BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext,
                                                     AssetBundleManifest unityManifest)
        {
            List <PatchBundle> result = new List <PatchBundle>();

            // 加载DLC
            DLCManager dlcManager = new DLCManager();

            dlcManager.LoadAllDLC();

            // 加载旧补丁清单
            PatchManifest oldPatchManifest = AssetBundleBuilder.LoadPatchManifestFile(buildParameters);

            // 获取加密列表
            List <string> encryptList = encryptionContext.EncryptList;

            string[] allAssetBundles = unityManifest.GetAllAssetBundles();
            foreach (var bundleName in allAssetBundles)
            {
                string   path      = $"{buildParameters.OutputDirectory}/{bundleName}";
                string   hash      = HashUtility.FileMD5(path);
                string   crc       = HashUtility.FileCRC32(path);
                long     size      = FileUtility.GetFileSize(path);
                int      version   = buildParameters.BuildVersion;
                string[] assets    = buildMapContext.GetCollectAssetPaths(bundleName);
                string[] depends   = unityManifest.GetDirectDependencies(bundleName);
                string[] dlcLabels = dlcManager.GetAssetBundleDLCLabels(bundleName);

                // 创建标记位
                bool isEncrypted = encryptList.Contains(bundleName);
                int  flags       = PatchBundle.CreateFlags(isEncrypted);

                // 注意:如果文件没有变化使用旧版本号
                if (oldPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle oldElement))
                {
                    if (oldElement.Hash == hash)
                    {
                        version = oldElement.Version;
                    }
                }

                PatchBundle newElement = new PatchBundle(bundleName, hash, crc, size, version, flags, assets, depends, dlcLabels);
                result.Add(newElement);
            }

            return(result);
        }
    private static void LoadDependenciePaths()
    {
        dependenciePathsDic.Clear();


        string[] sArr = s_manifest.GetAllAssetBundles();
        for (int i = 0; i < sArr.Length; i++)
        {
            string assetPath = sArr[i];
            //string assetName = Path.GetFileNameWithoutExtension(assetPath);
            string[] dependenPaths = s_manifest.GetDirectDependencies(assetPath);
            //Debug.Log("===========>>"+assetPath);
            string[] dependens = new string[dependenPaths.Length];
            for (int j = 0; j < dependenPaths.Length; j++)
            {
                dependens[j] = ResourcesConfigManager.GetLoadPathBase(ResourceManager.LoadType, dependenPaths[j]);
            }

            dependenciePathsDic.Add(ResourcesConfigManager.GetLoadPathBase(ResourceManager.LoadType, assetPath), dependens);
        }

        hasDependenciesPathList.Clear();
        foreach (var assetPath in dependenciePathsDic.Keys)
        {
            bool hasDep = false;
            foreach (var depList in dependenciePathsDic.Values)
            {
                foreach (var item in depList)
                {
                    if (item == assetPath)
                    {
                        hasDep = true;
                        hasDependenciesPathList.Add(assetPath);
                        break;
                    }
                }
                if (hasDep)
                {
                    break;
                }
            }
            //if (!hasDep)
            //{
            //    Debug.Log("没有依赖:" + assetPath);
            //}
        }
    }
        /// <summary>
        /// 获取资源包列表
        /// </summary>
        private List <PatchBundle> GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters,
                                                     TaskGetBuildMap.BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext,
                                                     AssetBundleManifest unityManifest)
        {
            List <PatchBundle> result = new List <PatchBundle>();

            // 内置标记列表
            List <string> buildinTags = buildParameters.Parameters.GetBuildinTags();

            // 加载旧补丁清单
            PatchManifest oldPatchManifest = null;

            if (buildParameters.Parameters.IsForceRebuild == false)
            {
                oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
            }

            string[] allAssetBundles = unityManifest.GetAllAssetBundles();
            foreach (var bundleName in allAssetBundles)
            {
                string   path          = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
                string   hash          = HashUtility.FileMD5(path);
                string   crc           = HashUtility.FileCRC32(path);
                long     size          = FileUtility.GetFileSize(path);
                int      version       = buildParameters.Parameters.BuildVersion;
                string[] collectAssets = buildMapContext.GetCollectAssetPaths(bundleName);
                string[] depends       = unityManifest.GetDirectDependencies(bundleName);
                string[] tags          = buildMapContext.GetAssetTags(bundleName);
                bool     isEncrypted   = encryptionContext.IsEncryptFile(bundleName);
                bool     isBuildin     = IsBuildinBundle(tags, buildinTags);

                // 注意:如果文件没有变化使用旧版本号
                if (oldPatchManifest != null && oldPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle value))
                {
                    if (value.Hash == hash)
                    {
                        version = value.Version;
                    }
                }

                PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc, size, version, collectAssets, depends, tags);
                patchBundle.SetFlagsValue(isEncrypted, isBuildin);
                result.Add(patchBundle);
            }

            return(result);
        }
        public string[] GetDirectDependencies(string assetBundleName)
        {
            assetBundleName = GetAssetBundleNameByAssetPath(assetBundleName);
            AssetBundleManifest manifest = GetAssetBundleManifest(assetBundleName);

            if (manifest != null)
            {
                string[] paths = manifest.GetDirectDependencies(assetBundleName);

                List <string> list = new List <string>(paths.Length);
                for (int i = 0; i < paths.Length; i++)
                {
                    list.Add(paths[i].Replace(ResourceFileUtil.ASSET_BUNDLE_EXTENSION, ""));
                }
                return(list.ToArray());
            }
            return(new string[] { });
        }
 private void LoadDependecies(string abName, string groupName)
 {
     if (_assetBundleManifest == null)
     {
         Debug.Log($"_assetBundleManifest还未初始化,未获取到{abName}的依赖信息");
         return;
     }
     string[] dependencys = _assetBundleManifest.GetDirectDependencies(abName); //得到需要加载的资源的依赖关系
     Debug.Log(string.Format("资源{0}的依赖数量为:{1}", abName, dependencys.Length));
     foreach (var item in dependencys)                                          //加载所有的依赖
     {
         Debug.Log($"资源{abName}的依赖有:{item}");
     }
     foreach (var dependency in dependencys) //加载所有的依赖
     {
         LoadSingle(dependency, groupName);
     }
 }
Exemple #18
0
    private bool CheckABIsCircleDependence(List <TempBundleEntry> rTempBundleEntries, AssetBundleManifest rABManifest,
                                           TempBundleEntry rBundleEntry)
    {
        rBundleEntry.CircleRefCount++;
        if (rBundleEntry.CircleRefCount > 1)
        {
            return(true);
        }

        var rDependences = rABManifest.GetDirectDependencies(rBundleEntry.Path);

        for (int i = 0; i < rDependences.Length; i++)
        {
            var rDependenceEntry = rTempBundleEntries.Find((rItem) => { return(rItem.Path.Equals(rDependences[i])); });
            return(this.CheckABIsCircleDependence(rTempBundleEntries, rABManifest, rDependenceEntry));
        }
        return(false);
    }
Exemple #19
0
        void OrderOneBundleCycle(AssetBundleManifest manifest, string name, ref List <string> orderedList)
        {
            if (orderedList.Contains(name))
            {
                return;
            }

            string[] allToOrder = manifest.GetDirectDependencies(name);
            if (allToOrder.Length == 0)
            {
                orderedList.Add(name);
            }

            foreach (string dep in allToOrder)
            {
                OrderOneBundleCycle(manifest, dep, ref orderedList);
            }
        }
Exemple #20
0
    IEnumerator LoadAssetBundleCR(string name, string key, bool lockLoadingScreen, bool loadAllDependencies = true)
    {
        // load the desired asset bundle and wait for it to complete
        string          uri     = "file:///" + bundlePath + name;
        UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri, 0);

        yield return(request.SendWebRequest());

        AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);

        // store the loaded asset bundle
        if (!bundleDict.ContainsKey(name))
        {
            bundleDict.Add(name, bundle);
        }
        else if (bundleDict[name] == null)
        {
            bundleDict[name] = bundle;
        }

        if (manifest != null)
        {
            if (loadAllDependencies)
            {
                // load all dependencies for asset bundle if requested
                foreach (var dep in manifest.GetDirectDependencies(name))
                {
                    Coroutine c = null;
                    LoadAssetBundleAsync(dep, lockLoadingScreen, out c);
                    yield return(c);
                }
            }
        }

        // mark bundle as no longer loading
        if (loadingBundles.ContainsKey(name))
        {
            loadingBundles.Remove(name);
        }

        // if behind loading screen remove locker
        //if (lockLoadingScreen)
        //	LoadingScreen.GetActiveLoadingScreen().RemoveLoadingLocker(key);
    }
Exemple #21
0
        private ABItem LoadABAndDependencies(string abName)
        {
            ABItem item = _assetBundles.Find(abItem => abItem.path == abName);

            if (item == null)
            {
                item = new ABItem(abName);
                _assetBundles.Add(item);
            }

            Assert.IsNotNull(_manifest);
            string[] dependencies = _manifest.GetDirectDependencies(abName);
            foreach (var dependency in dependencies)
            {
                LoadABAndDependencies(dependency);
            }
            _assetBundlesTemp.Add(item);
            return(item);
        }
Exemple #22
0
 /// <summary>
 /// 递归
 /// </summary>
 /// <param name="mainbundName"></param>
 /// <param name="AbDependenciesNameList"></param>
 void ToFindDirectDependencies(string mainbundName, ref List <string> AbDependenciesNameList)
 {
     if (!AbDependenciesNameList.Contains(mainbundName))
     {
         AbDependenciesNameList.Add(mainbundName);
     }
     string[] dependBundlePaths = m_AssetBundleManifest.GetDirectDependencies(mainbundName);
     if (dependBundlePaths != null && dependBundlePaths.Length > 0)
     {
         foreach (var path in dependBundlePaths)
         {
             if (!AbDependenciesNameList.Contains(path))
             {
                 AbDependenciesNameList.Add(path);
                 ToFindDirectDependencies(path, ref AbDependenciesNameList);
             }
         }
     }
 }
Exemple #23
0
        /// <summary>
        /// 将unity依赖转为自己的
        /// </summary>
        /// <param name="mainfest"></param>
        /// <returns></returns>
        public static DependenciesData Manifest2Dependence(AssetBundleManifest mainfest)
        {
            string[] abNames = mainfest.GetAllAssetBundles();

            List <SingleDepenciesData> singleDatas = new List <SingleDepenciesData>();

            for (int j = 0; j < abNames.Length; j++)
            {
                var dpNames = mainfest.GetDirectDependencies(abNames[j]);
                if (dpNames.Length <= 0)
                {
                    continue;
                }
                singleDatas.Add(new SingleDepenciesData(abNames[j], dpNames));
            }
            var data = new DependenciesData(singleDatas.ToArray());

            return(data);
        }
Exemple #24
0
        public bool VersionUp(AssetBundleManifest manifest)
        {
            Hash128 oladHash = Hash;
            Hash128 newHash  = manifest.GetAssetBundleHash(Name);

            if (oladHash.Equals(newHash))
            {
                return(false);
            }
            else
            {
                this.Version++;
                this.Hash               = newHash;
                this.AllDependencies    = manifest.GetAllDependencies(Name);
                this.DirectDependencies = manifest.GetDirectDependencies(Name);
                Debug.Log("AssetBundle" + Name + " is uped to Version " + Version);
                return(true);
            }
        }
        /// <summary>
        /// 分析Unity5方式的依赖构成
        /// </summary>
        /// <param name="directoryPath"></param>
        /// <returns></returns>
        private static List <AssetBundleFileInfo> AnalyzeManifestDepend(string directoryPath)
        {
            string manifestName = Path.GetFileName(directoryPath);
            string manifestPath = Path.Combine(directoryPath, manifestName);

            if (!File.Exists(manifestPath))
            {
                Debug.LogWarning(manifestPath + " is not exists! Use AnalyzAllFiles ...");
                return(null);
            }
#if UNITY_5_3_OR_NEWER
            AssetBundle manifestAb = AssetBundle.LoadFromFile(manifestPath);
#else
            AssetBundle manifestAb = AssetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(manifestPath));
#endif
            if (!manifestAb)
            {
                Debug.LogError(manifestPath + " ab load faild!");
                return(null);
            }

            List <AssetBundleFileInfo> infos = new List <AssetBundleFileInfo>();
#if UNITY_5 || UNITY_5_3_OR_NEWER
            AssetBundleManifest assetBundleManifest = manifestAb.LoadAsset <AssetBundleManifest>("assetbundlemanifest");
            var bundles = assetBundleManifest.GetAllAssetBundles();
            foreach (var bundle in bundles)
            {
                string path = Path.Combine(directoryPath, bundle);
                AssetBundleFileInfo info = new AssetBundleFileInfo
                {
                    name          = bundle,
                    path          = path,
                    rootPath      = directoryPath,
                    size          = new FileInfo(path).Length,
                    directDepends = assetBundleManifest.GetDirectDependencies(bundle),
                    allDepends    = assetBundleManifest.GetAllDependencies(bundle)
                };
                infos.Add(info);
            }
#endif
            manifestAb.Unload(true);
            return(infos);
        }
Exemple #26
0
    public static bool CircleCheckDFS(string assetName, List <string> currentLine, Dictionary <string, bool> resultMap, AssetBundleManifest manifest)
    {
        if (resultMap.ContainsKey(assetName) && resultMap[assetName])
        {
            return(true);
        }

        int index = currentLine.IndexOf(assetName);

        if (index >= 0)
        {
            string circle = "";

            for (int i = index; i < currentLine.Count; ++i)
            {
                circle += currentLine[i];
                circle += "=>";
            }

            circle += assetName;

            Debug.LogError("Circle dependence detected:\n" + circle);
            return(false);
        }

        currentLine.Add(assetName);

        string[] assetNames = manifest.GetDirectDependencies(assetName);
        foreach (string name in assetNames)
        {
            if (!CircleCheckDFS(name, currentLine, resultMap, manifest))
            {
                return(false);
            }
        }

        currentLine.RemoveAt(currentLine.Count - 1);

        resultMap.Add(assetName, true);

        return(true);
    }
Exemple #27
0
    public static void SaveDependency()
    {
        string dir = GetBundleSaveDir(BuildTarget.StandaloneWindows64);
        //Debug.Log(dir.TrimEnd('/'));
        string depfile = dir.Substring(dir.TrimEnd('/').LastIndexOf("/") + 1);
        //Debug.Log(depfile.TrimEnd('/'));
        string path = GetBundleSavePath(BuildTarget.StandaloneWindows64, depfile.TrimEnd('/'));
        // Debug.Log(path);
        AssetBundle ab = AssetBundle.LoadFromFile(path);

        AssetBundleManifest mainfest = (AssetBundleManifest)ab.LoadAsset("AssetBundleManifest");

        ab.Unload(false);

        //保存所有的依赖文件
        Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >();

        LoadOldDependency(BuildTarget.StandaloneWindows64, dic);

        foreach (string asset in mainfest.GetAllAssetBundles())
        {
            //Debug.Log("asset:"+asset);
            List <string> list = new List <string>();
            string[]      deps = mainfest.GetDirectDependencies(asset); //获取每一个对象的直接依赖
            foreach (string dep in deps)
            {
                // Debug.Log("dep:"+dep);
                list.Add(dep);
            }
            //去重
            if (deps.Length > 0)
            {
                dic[asset] = list;
            }
            else if (dic.ContainsKey(asset))
            {
                dic.Remove(asset);
            }
        }

        WriteDependenceConfig(BuildTarget.StandaloneWindows64, dic);
    }
Exemple #28
0
    AssetBundleManifest assetBundleManifestLocalLoad;   //递归加载时候用
    public void RecursionLoadAssetFromLocalFile(string RootAssetsName, string AssetName, string LocalPath, int RecursionCounter)
    {
        if (RecursionCounter++ == 0)
        {
            //加载本地Manifest获取依赖项
            assetBundleManifestLocalLoad = AssetBundle.LoadFromFile(LocalPath + "/" + RootAssetsName).LoadAsset <AssetBundleManifest>("AssetBundleManifest");
        }

        //当前AssetName所有依赖项
        string[] AllDependencies = assetBundleManifestLocalLoad.GetDirectDependencies(AssetName);

        for (int i = 0; i < AllDependencies.Length; i++)
        {
            RecursionLoadAssetFromLocalFile(RootAssetsName, AllDependencies[i], LocalPath, RecursionCounter);
        }

        AssetBundle assetBundle = AssetBundle.LoadFromFile(LocalPath + "/" + AssetName);

        assetBundle.LoadAllAssets();
    }
Exemple #29
0
    public static int GetDirectDependencies(IntPtr l)
    {
        int result;

        try
        {
            AssetBundleManifest assetBundleManifest = (AssetBundleManifest)LuaObject.checkSelf(l);
            string assetBundleName;
            LuaObject.checkType(l, 2, out assetBundleName);
            string[] directDependencies = assetBundleManifest.GetDirectDependencies(assetBundleName);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, directDependencies);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemple #30
0
    /// <summary>
    /// 记录本次打包所有的AB依赖信息
    /// 通过把每一个AB缩写一个同名的*.d文件来记录AB依赖关系
    /// </summary>
    private static void recordAllABDpInfo()
    {
        var manifestfile             = AssetBundle.LoadFromFile(ABHelper.Singleton.CurrentPlatformABManifestFilePath);
        AssetBundleManifest manifest = manifestfile.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

        if (manifest == null)
        {
            Debug.LogError("加载AssetBundleManifest文件失敗!");
            return;
        }
        else
        {
            var allassetbundle = manifest.GetAllAssetBundles();
            foreach (var assetbundle in allassetbundle)
            {
                var dpassetbundles = manifest.GetDirectDependencies(assetbundle);
                ABHelper.Singleton.writeAssetBundleDpToFile(assetbundle, dpassetbundles);
            }
        }
    }