Beispiel #1
0
        public static void RefreshModulesInfo(List<AssetInfo> infos, BuildArtifactsInfo artifactsInfo)
        {
            if (artifactsInfo.managedModules.Count <= 0)
                return;

            var modulesSuspects = infos.Where(x => x.path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                                    .ToLookup(x => ReliablePath.GetFileName(x.path));

            // add modules
            foreach (var kv in artifactsInfo.managedModules)
            {
                var existingEntries = modulesSuspects[kv.Key].ToList();
                if (existingEntries.Any())
                {
                    foreach (var entry in existingEntries)
                    {
                        entry.size += kv.Value.uncompressed;
                        UpdateCompressedSize(entry, kv.Value.compressed);
                    }
                }
                else
                {
                    var entry = new AssetInfo()
                    {
                        path = kv.Key,
                        size = kv.Value.uncompressed,
                    };
                    UpdateCompressedSize(entry, kv.Value.compressed);
                    infos.Add(entry);
                }
            }
        }
Beispiel #2
0
        public static void RefreshScenesInfo(Dictionary<string, long> scenesSizes, List<AssetInfo> infos, BuildArtifactsInfo artifactsInfo, List<string> processedScenes, List<AssetProperty[]> scenesDetails, BuildInfoAssetDetailsCollector collector)
        {
            Dictionary<string, AssetInfo> scenesInfo = new Dictionary<string, AssetInfo>();

            // if there are missing scenes... add them
            foreach (var scenePath in processedScenes.Distinct())
            {
                var info = new AssetInfo()
                {
                    path = scenePath,
                    scenes = { scenePath }
                };

                long size;
                scenesSizes.TryGetValue(scenePath, out size);
                info.size = size;

                scenesInfo.Add(scenePath, info);
            }

            if (collector != null)
            {
                foreach (var sceneInfo in scenesInfo.Values)
                {
                    var index = processedScenes.FindIndex(x => string.Compare(x, sceneInfo.path, true) == 0);
                    if (index >= 0)
                        sceneInfo.details = CleanUpAssetsDetails(scenesDetails[index], sceneInfo.path);
                    else
                        Log.Warning("Unable to find details for level {0}", sceneInfo.path);
                }
            }

            infos.AddRange(scenesInfo.Values);

            if (artifactsInfo != null)
            {
                for (int i = 0; i < artifactsInfo.sceneSizes.Count; ++i)
                {
                    if (i >= processedScenes.Count)
                    {
            #if !UNITY_2017_1_OR_NEWER
                        Log.Warning("Detected more scenes in the build than been notified of ({0} vs {1})", artifactsInfo.sceneSizes.Count, processedScenes.Count);
            #endif
                        break;
                    }

                    if (artifactsInfo.sceneSizes[i].uncompressed == 0)
                    {
                        Log.Warning("No size for {0}", processedScenes[i]);
                    }

                    AssetInfo sceneInfo = scenesInfo[processedScenes[i]];

                    sceneInfo.size = System.Math.Max(artifactsInfo.sceneSizes[i].uncompressed, sceneInfo.size);
                    UpdateCompressedSize(sceneInfo, artifactsInfo.sceneSizes[i].compressed);
                }
            }
        }
Beispiel #3
0
        public static void RefreshOtherArtifacts(List<AssetInfo> sortedInfos, BuildArtifactsInfo artifactsInfo)
        {
            System.Action<string, long, long> forceUpdateAsset = (assetPath, uncompressed, compressed) =>
            {
                if (uncompressed == 0)
                    return;

                int index = FindInfoIndexByPath(sortedInfos, assetPath);
                if (index < 0)
                {
                    // "unity default resources" seems to move around between releases... so override here, just in case
                    if (assetPath.EndsWith("unity default resources"))
                    {
                        var overrideInfo = new AssetInfo() { path = "Library/unity default resources" };
                        var overrideIndex = sortedInfos.BinarySearch(overrideInfo, PathComparer);
                        if (overrideIndex >= 0)
                        {
                            index = overrideIndex;
                        }
                    }
                }

                AssetInfo info;
                if (index >= 0)
                {
                    info = sortedInfos[index];
                }
                else
                {
                    Log.Debug("Unknown asset: {0}, adding from build artifacts with zero dependencies", assetPath);
                    info = new AssetInfo() { path = assetPath };
                    sortedInfos.Insert(~index, info);
                }

                if (uncompressed > 0)
                {
                    Log.Debug("Overriding {0} size from {1} to {2} based on build artifacts", assetPath, info.size, uncompressed);
                    info.size = uncompressed; // questionable
                }

                long prevCompressedSize = UpdateCompressedSize(info, compressed);
                if (prevCompressedSize > 0)
                {
                    Log.Debug("Already had compressed size for {0}: {1} vs {2}", assetPath, prevCompressedSize, compressed);
                }
            };

            foreach (var res in artifactsInfo.unityResources)
            {
                forceUpdateAsset(res.Key, res.Value.uncompressed, res.Value.compressed);
            }

            foreach (var asset in artifactsInfo.otherAssets)
            {
                var assetPath = AssetDatabase.GUIDToAssetPath(asset.Key);
                if (string.IsNullOrEmpty(assetPath))
                    continue;

                forceUpdateAsset(assetPath, asset.Value.uncompressed, asset.Value.compressed);
            }
        }