コード例 #1
0
ファイル: BRT_BuildInfo.cs プロジェクト: lxc1030/ServerTest
        /// <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
        }
コード例 #2
0
        public void PopulateImportedSizes()
        {
            long importedSize = -1;

            for (int n = 0, len = _all.Length; n < len; ++n)
            {
                /*if (BuildReportTool.Util.IsFileAUnityAsset(_all[n].Name))
                 * {
                 *      // Scene files/terrain files/scriptable object files/etc. always seem to be only 4kb in the library,
                 *      // no matter how large the actual file in the assets folder really is.
                 *      // The 4kb is probably just metadata/reference to the actual file itself.
                 *      // Makes sense since these file types are "native" to unity, so no importing is necessary.
                 *      //
                 *      // In this case, the raw size (size of the file in the assets folder) counts as the imported size
                 *      // so just use the raw size.
                 *
                 *      _all[n].ImportedSizeBytes = _all[n].RawSizeBytes;
                 *      _all[n].ImportedSize = _all[n].RawSize;
                 * }
                 * else*/
                {
                    importedSize = BRT_LibCacheUtil.GetImportedFileSize(_all[n].Name);

                    _all[n].ImportedSizeBytes = importedSize;
                    _all[n].ImportedSize      = BuildReportTool.Util.GetBytesReadable(importedSize);
                }
            }
        }
コード例 #3
0
ファイル: BRT_BuildInfo.cs プロジェクト: yymqwl/NovelGame
        long GetSizeSumForUsedAssets(string assetFolderName, Func <string, bool> fileTypePredicate)
        {
            if (UsedAssets == null || UsedAssets.All == null)
            {
                return(0);
            }

            return(UsedAssets.All.Where(part => BuildReportTool.Util.IsFileInAPath(part.Name, assetFolderName) && fileTypePredicate(part.Name))
                   .Sum(part => BRT_LibCacheUtil.GetImportedFileSize(part.Name)));
        }
コード例 #4
0
        public void PopulateImportedSizes()
        {
            long importedSize = -1;

            for (int n = 0, len = _all.Length; n < len; ++n)
            {
                importedSize = BRT_LibCacheUtil.GetImportedFileSize(_all[n].Name);

                _all[n].ImportedSizeBytes = importedSize;
                _all[n].ImportedSize      = BuildReportTool.Util.GetBytesReadable(importedSize);
            }
        }
コード例 #5
0
ファイル: BRT_BuildInfo.cs プロジェクト: yymqwl/NovelGame
        /// <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
        }