Esempio n. 1
0
    public static IEnumerator GetDepMap(string baseUrl, string hash)
    {
        string url = baseUrl + hash + ".depmap";

        LoadPersistentCache();

        if (dependenciesMap.ContainsKey(hash))
        {
            yield break;
        }

        if (failedRequests.Contains(hash))
        {
            yield break;
        }

        if (downloadingDepmap.Contains(hash))
        {
            yield return(WaitUntilDepMapIsResolved(hash));

            yield break;
        }

        using (UnityWebRequest depmapRequest = UnityWebRequest.Get(url))
        {
            downloadingDepmap.Add(hash);

            yield return(depmapRequest.SendWebRequest());

            if (!depmapRequest.WebRequestSucceded())
            {
                failedRequests.Add(hash);
                downloadingDepmap.Remove(hash);
                yield break;
            }

            AssetDependencyMap map = JsonUtility.FromJson <AssetDependencyMap>(depmapRequest.downloadHandler.text);
            map.dependencies = map.dependencies.Where(x => !x.Contains("mainshader")).ToArray();

            dependenciesMap.Add(hash, new List <string>(map.dependencies));

            downloadingDepmap.Remove(hash);

            if (DCLTime.realtimeSinceStartup - lastTimeSavedPersistentCache >= MIN_TIME_BETWEEN_SAVING_PERSISTENT_CACHE)
            {
                SavePersistentCache();
            }
        }
    }
        /// <summary>
        /// This dumps .depmap files
        /// </summary>
        /// <param name="manifest"></param>
        public static void Generate(IFile file, string path, Dictionary <string, string> hashLowercaseToHashProper, AssetBundleManifest manifest, string exceptions = null)
        {
            string[] assetBundles = manifest.GetAllAssetBundles();

            for (int i = 0; i < assetBundles.Length; i++)
            {
                if (string.IsNullOrEmpty(assetBundles[i]))
                {
                    continue;
                }

                var      depMap = new AssetDependencyMap();
                string[] deps   = manifest.GetAllDependencies(assetBundles[i]);

                if (deps.Length > 0)
                {
                    deps = deps.Where(s => s != exceptions).ToArray();

                    depMap.dependencies = deps.Select((x) =>
                    {
                        if (hashLowercaseToHashProper.ContainsKey(x))
                        {
                            return(hashLowercaseToHashProper[x]);
                        }
                        else
                        {
                            return(x);
                        }
                    })
                                          .ToArray();
                }

                string json          = JsonUtility.ToJson(depMap);
                string finalFilename = assetBundles[i];

                hashLowercaseToHashProper.TryGetValue(assetBundles[i], out finalFilename);

                if (!string.IsNullOrEmpty(finalFilename))
                {
                    file.WriteAllText(path + finalFilename + ".depmap", json);
                }
            }
        }
Esempio n. 3
0
    public static IEnumerator GetDepMap(string baseUrl, string hash)
    {
        string url = baseUrl + hash + ".depmap";

        if (failedRequests.Contains(hash))
        {
            yield break;
        }

        if (dependenciesMap.ContainsKey(hash))
        {
            yield break;
        }

        if (downloadingDepmap.Contains(hash))
        {
            yield return(WaitUntilDepMapIsResolved(hash));

            yield break;
        }

        using (UnityWebRequest depmapRequest = UnityWebRequest.Get(url))
        {
            downloadingDepmap.Add(hash);

            yield return(depmapRequest.SendWebRequest());

            if (!depmapRequest.WebRequestSucceded())
            {
                failedRequests.Add(hash);
                downloadingDepmap.Remove(hash);
                yield break;
            }

            AssetDependencyMap map = JsonUtility.FromJson <AssetDependencyMap>(depmapRequest.downloadHandler.text);

            dependenciesMap.Add(hash, new List <string>(map.dependencies));
            downloadingDepmap.Remove(hash);
        }
    }