| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.IO; |
| | 4 | | using System.Linq; |
| | 5 | | using System.Runtime.CompilerServices; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | [assembly: InternalsVisibleTo("AssetBundleBuilderEditorTests")] |
| | 9 | |
|
| | 10 | | namespace DCL.ABConverter |
| | 11 | | { |
| | 12 | | public static class DependencyMapBuilder |
| | 13 | | { |
| | 14 | | [System.Serializable] |
| | 15 | | public class AssetDependencyMap |
| | 16 | | { |
| | 17 | | public string[] dependencies; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// This dumps .depmap files |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="manifest"></param> |
| | 24 | | public static void Generate(IFile file, string path, Dictionary<string, string> hashLowercaseToHashProper, Asset |
| | 25 | | { |
| 0 | 26 | | string[] assetBundles = manifest.GetAllAssetBundles(); |
| | 27 | |
|
| 0 | 28 | | for (int i = 0; i < assetBundles.Length; i++) |
| | 29 | | { |
| 0 | 30 | | if (string.IsNullOrEmpty(assetBundles[i])) |
| | 31 | | continue; |
| | 32 | |
|
| 0 | 33 | | var depMap = new AssetDependencyMap(); |
| 0 | 34 | | string[] deps = manifest.GetAllDependencies(assetBundles[i]); |
| | 35 | |
|
| 0 | 36 | | if (deps.Length > 0) |
| | 37 | | { |
| 0 | 38 | | deps = deps.Where(s => s != exceptions).ToArray(); |
| | 39 | |
|
| 0 | 40 | | depMap.dependencies = deps.Select((x) => |
| | 41 | | { |
| 0 | 42 | | if (hashLowercaseToHashProper.ContainsKey(x)) |
| 0 | 43 | | return hashLowercaseToHashProper[x]; |
| | 44 | | else |
| 0 | 45 | | return x; |
| | 46 | | }) |
| | 47 | | .ToArray(); |
| | 48 | | } |
| | 49 | |
|
| 0 | 50 | | string json = JsonUtility.ToJson(depMap); |
| 0 | 51 | | string finalFilename = assetBundles[i]; |
| | 52 | |
|
| 0 | 53 | | hashLowercaseToHashProper.TryGetValue(assetBundles[i], out finalFilename); |
| | 54 | |
|
| 0 | 55 | | if (!string.IsNullOrEmpty(finalFilename)) |
| | 56 | | { |
| 0 | 57 | | file.WriteAllText(path + finalFilename + ".depmap", json); |
| | 58 | | } |
| | 59 | | } |
| 0 | 60 | | } |
| | 61 | | } |
| | 62 | | } |