Ejemplo n.º 1
0
    void OnGUI()
    {
        GUIStyle style = new GUIStyle();

        style.wordWrap         = true;
        style.normal.textColor = Color.white;

        GUILayout.BeginVertical();
        if (GUILayout.Button("log dupes"))
        {
            compareAssetList(UsedAssets.GetAllAssets());
            m_Init = true;
        }
        if (m_Init && !m_Found)
        {
            style.normal.textColor = Color.green;
            GUILayout.Label("\nNo dumplicates found :-D\n\n", style);
            style.normal.textColor = Color.white;
        }
        else if (m_Init && m_Found)
        {
            style.normal.textColor = Color.red;
            string s = "";
            foreach (string t in m_Strings)

            {
                s = s + t + "\n";
            }
            GUILayout.Label("\nduplicates found !!!\n\n" + s, style);
            style.normal.textColor = Color.white;
        }
        GUILayout.EndVertical();
    }
Ejemplo n.º 2
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.º 3
0
        void RecalculatePercentages()
        {
            //Debug.Log("RecalculatePercentages() called");


            double totalSize = GetTotalSize();

            //Debug.LogFormat("BuildSizes total: {0}", totalSize);

            for (int n = 0, len = BuildSizes.Length; n < len; ++n)
            {
                BuildSizes[n].Percentage = System.Math.Round((BuildSizes[n].UsableSize / totalSize) * 100, 2,
                                                             System.MidpointRounding.AwayFromZero);
            }


            // note: only Used Assets are shown the percentages so we
            // don't bother recalculating percentage for Unused Assets
            if (UsedAssets != null)
            {
                UsedAssets.RecalculatePercentages(totalSize);
            }

            ChangeTotalSize(totalSize);
        }
Ejemplo n.º 4
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);
            }
        }
    private void loadEditorLog()
    {
        UsedAssets.GetLists(ref usedAssets, ref includedDependencies);

        if (usedAssets.Count == 0)
        {
            needToBuild = true;
        }
        else
        {
            foreach (string s in usedAssets)
            {
                //if (assets.Contains(s))
                {
                    UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(s, typeof(UnityEngine.Object));
                    if (obj != null)
                    {
                        usedObjects.Add(new KeyValuePair <string, UnityEngine.Object>(s, obj));
                    }
                }
            }

            groupEnabled = true;
            needToBuild  = false;
        }
    }
Ejemplo n.º 6
0
        public void UnescapeAssetNames()
        {
            if (UsedAssets != null)
            {
                UsedAssets.UnescapeAssetNames();
            }

            if (UnusedAssets != null)
            {
                UnusedAssets.UnescapeAssetNames();
            }
        }
Ejemplo n.º 7
0
    private void loadEditorLog()
    {
        UsedAssets.GetLists(ref usedAssets, ref includedDependencies);

        if (usedAssets.Count == 0)
        {
            needToBuild = true;
        }
        else
        {
            compareAssetList(UsedAssets.GetAllAssets());
            groupEnabled = true;
            needToBuild  = false;
        }
    }
Ejemplo n.º 8
0
        void RecalculatePercentages()
        {
            double totalSize = GetTotalSize();

            if (totalSize > 0)
            {
                for (int n = 0, len = BuildSizes.Length; n < len; ++n)
                {
                    BuildSizes[n].Percentage = Math.Round((BuildSizes[n].UsableSize / totalSize) * 100, 2, MidpointRounding.AwayFromZero);
                }
            }

            // note: only Used Assets are shown the percentages so we
            // don't bother recaulculating percentage for Unused Assets
            if (UsedAssets != null)
            {
                UsedAssets.RecalculatePercentages(totalSize);
            }
        }
Ejemplo n.º 9
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
        }