Ejemplo n.º 1
0
        /// <summary>
        /// This is called right after generating a build report.
        /// </summary>
        public void FixSizes()
        {
#if UNITY_5_2_AND_LESSER
            // this bug has already been fixed since Unity 5.2.1
            // so we only execute this for Unity 5.2.0 and below

            if (DldUtil.UnityVersion.IsUnityVersionAtLeast(5, 2, 1))
            {
                return;
            }

            // --------------------------------------------------------------------------------
            // fix imported sizes of Resources files

            for (int n = 0; n < UsedAssets.All.Length; ++n)
            {
                if (BuildReportTool.Util.IsFileInAPath(UsedAssets.All[n].Name, "/Resources/"))
                {
                    UsedAssets.All[n].ImportedSizeBytes = BRT_LibCacheUtil.GetImportedFileSize(UsedAssets.All[n].Name);
                    UsedAssets.All[n].ImportedSize      = BuildReportTool.Util.GetBytesReadable(UsedAssets.All[n].ImportedSizeBytes);

                    UsedAssets.All[n].RawSizeBytes = UsedAssets.All[n].ImportedSizeBytes;
                    UsedAssets.All[n].RawSize      = UsedAssets.All[n].ImportedSize;

                    UsedAssets.All[n].DerivedSize = 0;
                    UsedAssets.All[n].Percentage  = -1;
                }
            }

            UsedAssets.ResortDefault();

            // --------------------------------------------------------------------------------
            // recalculate percentages

            // add textures, meshes, sounds, and animations that are in resources folder to the build size
            // since they are not included anymore in Unity 5

            var resourcesTextureSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnityTexture);
            AddToSize("Textures", resourcesTextureSizeSum);

            var resourcesMeshSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnityMesh);
            AddToSize("Meshes", resourcesMeshSizeSum);

            var resourcesSoundsSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnitySound);
            AddToSize("Sounds", resourcesSoundsSizeSum);

            var resourcesAnimationsSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnityAnimation);
            AddToSize("Animations", resourcesAnimationsSizeSum);

            AddToTotalSize(resourcesTextureSizeSum);
            AddToTotalSize(resourcesMeshSizeSum);
            AddToTotalSize(resourcesSoundsSizeSum);
            AddToTotalSize(resourcesAnimationsSizeSum);

            FixPercentages();

            // sort sizes again since we modified them
            SortSizes();
#endif
        }
Ejemplo n.º 2
0
        public void RecategorizeAssetLists()
        {
            FileFilterGroup fileFiltersToUse = FileFilters;

            if (BuildReportTool.Options.ShouldUseConfiguredFileFilters())
            {
                fileFiltersToUse = BuildReportTool.FiltersUsed.GetProperFileFilterGroupToUse();
                //Debug.Log("going to use configured file filters instead... loaded: " + (fileFiltersToUse != null));
            }

            if (UsedAssets != null)
            {
                UsedAssets.AssignPerCategoryList(
                    BuildReportTool.ReportGenerator.SegregateAssetSizesPerCategory(UsedAssets.All, fileFiltersToUse));

                UsedAssets.RefreshFilterLabels(fileFiltersToUse);

                UsedAssets.ResortDefault(BuildReportTool.Options.NumberOfTopLargestUsedAssetsToShow);
            }

            if (UnusedAssets != null)
            {
                UnusedAssets.AssignPerCategoryList(
                    BuildReportTool.ReportGenerator.SegregateAssetSizesPerCategory(UnusedAssets.All, fileFiltersToUse));

                UnusedAssets.RefreshFilterLabels(fileFiltersToUse);

                UnusedAssets.ResortDefault(BuildReportTool.Options.NumberOfTopLargestUnusedAssetsToShow);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is called right after generating a build report.
        /// </summary>
        public void FixReport()
        {
#if UNITY_5_2_AND_LESSER
            // this bug has already been fixed since Unity 5.2.1
            // so we only execute this for Unity 5.2.0 and below

            if (!DldUtil.UnityVersion.IsUnityVersionAtLeast(5, 2, 1))
            {
                // --------------------------------------------------------------------------------
                // fix imported sizes of Resources files

                for (int n = 0; n < UsedAssets.All.Length; ++n)
                {
                    if (BuildReportTool.Util.IsFileInAPath(UsedAssets.All[n].Name, "/Resources/"))
                    {
                        UsedAssets.All[n].ImportedSizeBytes = BRT_LibCacheUtil.GetImportedFileSize(UsedAssets.All[n].Name);
                        UsedAssets.All[n].ImportedSize      = BuildReportTool.Util.GetBytesReadable(UsedAssets.All[n].ImportedSizeBytes);

                        UsedAssets.All[n].RawSizeBytes = UsedAssets.All[n].ImportedSizeBytes;
                        UsedAssets.All[n].RawSize      = UsedAssets.All[n].ImportedSize;

                        UsedAssets.All[n].DerivedSize = 0;
                        UsedAssets.All[n].Percentage  = -1;
                    }
                }

                UsedAssets.ResortDefault(BuildReportTool.Options.NumberOfTopLargestUsedAssetsToShow);

                // --------------------------------------------------------------------------------
                // recalculate percentages

                var totalSizePart = BuildSizes.FirstOrDefault(part => part.IsTotal);
                if (totalSizePart != null && totalSizePart.DerivedSize == 0)
                {
                    var totalSize = GetTotalSize();
                    ChangeTotalSize(totalSize);
                }

                // add textures, meshes, sounds, and animations that are in resources folder to the build size
                // since they are not included anymore in Unity 5

                var resourcesTextureSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnityTexture);
                AddToSize("Textures", resourcesTextureSizeSum);

                var resourcesMeshSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnityMesh);
                AddToSize("Meshes", resourcesMeshSizeSum);

                var resourcesSoundsSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnitySound);
                AddToSize("Sounds", resourcesSoundsSizeSum);

                var resourcesAnimationsSizeSum = GetSizeSumForUsedAssets("/Resources/", BuildReportTool.Util.IsFileAUnityAnimation);
                AddToSize("Animations", resourcesAnimationsSizeSum);

                AddToTotalSize(resourcesTextureSizeSum);
                AddToTotalSize(resourcesMeshSizeSum);
                AddToTotalSize(resourcesSoundsSizeSum);
                AddToTotalSize(resourcesAnimationsSizeSum);

                RecalculatePercentages();

                // sort sizes again since we modified them
                SortSizes();
            }
#else
            // newer versions of Unity (2017 and up)
            // has a bug where the total size reported is actually the final build's size,
            // instead of the total of the sizes indicated in the build log.
            // so we recalculate the percentages.
            // this is most noticeable when the percentages
            // indicated don't really total up to 100, not even close to 90
            RecalculatePercentages();

            // sort sizes again since we modified them
            SortSizes();
#endif
        }