示例#1
0
        private void DrawWarnings(SpriteData spriteData)
        {
            if (!spriteData.HasWarnings())
            {
                return;
            }

            EditorGUILayout.LabelField("Warnings", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            EditorGUILayout.LabelField(spriteData.SpriteUsageFlags.ToString());

            if (spriteData.SpriteUsageFlags.HasFlag(SpriteUsageFlags.CantDiscoveryAllUsageSize))
            {
                EditorGUILayout.LabelField(new GUIContent(
                                               $"Cannot detect all sprite usages sizes!", SpriteAuditorGUIUtility.WarningIcon));
            }

            if (spriteData.MaximumUsageSize.HasValue)
            {
                float differenceMagnitude = spriteData.MaximumUsageSize.Value.magnitude /
                                            spriteData.SpriteSize.magnitude;

                if (spriteData.SpriteUsageFlags.HasFlag(SpriteUsageFlags.UsedBiggerThanSpriteRect))
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(new GUIContent(
                                                   $"Sprite is used {Mathf.Abs(1.0f-differenceMagnitude):P} bigger than original Sprite, you may scale it up",
                                                   SpriteAuditorGUIUtility.WarningIcon));

                    SpriteAuditorGUIUtility.DrawFixSpriteSize(spriteData);
                    EditorGUILayout.EndHorizontal();
                }

                if (spriteData.SpriteUsageFlags.HasFlag(SpriteUsageFlags.UsedSmallerThanSpriteRect))
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(new GUIContent(
                                                   $"Sprite is used {Mathf.Abs(1.0f - differenceMagnitude):P} smaller than original Sprite, you may scale it down",
                                                   SpriteAuditorGUIUtility.WarningIcon));


                    SpriteAuditorGUIUtility.DrawFixSpriteSize(spriteData);
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUI.indentLevel--;
        }
示例#2
0
        protected virtual void DrawSpriteDataField(SpriteData spriteData)
        {
            EditorGUILayout.BeginVertical("Box");
            if (SpriteAuditorGUIUtility.DrawObjectFoldout(spriteData.Sprite, spriteData.Sprite.name))
            {
                EditorGUI.indentLevel++;

                DrawSpriteUsageCount(spriteData);

                DrawSpriteSizeDetails(spriteData);

                DrawSpriteReferencesPath(spriteData);

                DrawSpriteSceneReferences(spriteData);

                DrawWarnings(spriteData);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();
        }
示例#3
0
        protected override void DrawResultsInternal(SpriteDatabase spriteDatabase)
        {
            EditorGUILayout.BeginVertical("Box");
            if (usedSpriteDatas.Length > 0)
            {
                if (SpriteAuditorGUIUtility.DrawStringFoldout(
                        $"Used Sprites [{usedSpriteDatas.Length}] ",
                        $"{VisualizationType.Sprite.ToString()}_used_sprites"))
                {
                    EditorGUI.indentLevel++;
                    for (int i = 0; i < usedSpriteDatas.Length; i++)
                    {
                        SpriteData usedSpriteData = usedSpriteDatas[i];
                        DrawSpriteDataField(usedSpriteData);
                    }

                    EditorGUI.indentLevel--;
                }
            }

            if (unusedSprites.Length > 0)
            {
                if (SpriteAuditorGUIUtility.DrawStringFoldout(
                        $"Unused Sprites [{unusedSprites.Length}] ",
                        $"{VisualizationType.Sprite.ToString()}_unused_sprites"))
                {
                    for (int i = 0; i < unusedSprites.Length; i++)
                    {
                        Sprite sprite = unusedSprites[i];
                        SpriteAuditorGUIUtility.DrawObjectFoldout(sprite,
                                                                  $"{VisualizationType.Sprite.ToString()}_{sprite.name}", false);
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }
示例#4
0
        protected override void DrawResultsInternal(SpriteDatabase spriteDatabase)
        {
            for (int i = 0; i < filteredAtlas.Length; i++)
            {
                SpriteAtlas atlas = filteredAtlas[i];

                EditorGUILayout.BeginVertical("Box");

                if (SpriteAuditorGUIUtility.DrawObjectFoldout(atlas,
                                                              $"{VisualizationType.Atlas.ToString()}_{atlas.name}"))
                {
                    EditorGUI.indentLevel++;

                    if (atlasToUsedSprites[atlas].Length > 0)
                    {
                        if (SpriteAuditorGUIUtility.DrawStringFoldout(
                                $"Used Sprites [{atlasToUsedSprites[atlas].Length}] ",
                                $"{VisualizationType.Atlas.ToString()}_{atlas.name}_used_sprites"))
                        {
                            EditorGUI.indentLevel++;

                            for (int j = 0; j < atlasToUsedSprites[atlas].Length; j++)
                            {
                                SpriteData spriteData = atlasToUsedSprites[atlas][j];
                                DrawSpriteDataField(spriteData);
                            }

                            EditorGUI.indentLevel--;
                        }
                    }

                    if (atlasToNotUsedSprites[atlas].Length > 0)
                    {
                        if (SpriteAuditorGUIUtility.DrawStringFoldout(
                                $"Not Used Sprites [{atlasToNotUsedSprites[atlas].Length}] ",
                                $"{VisualizationType.Atlas.ToString()}_{atlas.name}_not_used_sprites"))
                        {
                            EditorGUI.indentLevel++;

                            for (int j = 0; j < atlasToNotUsedSprites[atlas].Length; j++)
                            {
                                Sprite sprite = atlasToNotUsedSprites[atlas][j];
                                if (sprite == null)
                                {
                                    continue;
                                }

                                SpriteAuditorGUIUtility.DrawObjectFoldout(sprite,
                                                                          $"{VisualizationType.Atlas.ToString()}_{atlas.name}_{sprite.name}", false);
                            }

                            EditorGUI.indentLevel--;
                        }
                    }

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.EndVertical();
            }
        }
        protected override void DrawResultsInternal(SpriteDatabase spriteDatabase)
        {
            if (uniqueUsedScenes == null)
            {
                return;
            }

            for (int i = 0; i < uniqueUsedScenes.Length; i++)
            {
                SceneAsset sceneAsset = uniqueUsedScenes[i];

                EditorGUILayout.BeginVertical("Box");

                if (SpriteAuditorGUIUtility.DrawObjectFoldout(sceneAsset, sceneAsset.name))
                {
                    EditorGUI.indentLevel++;
                    if (sceneToSingleSprites[sceneAsset].Length > 0)
                    {
                        EditorGUILayout.BeginVertical("Box");

                        if (SpriteAuditorGUIUtility.DrawStringFoldout($"Sprites Without Atlas [{sceneToSingleSprites[sceneAsset].Length}] ", $"{sceneAsset.name}_SceneViewSpritesWithoutAtlas"))
                        {
                            EditorGUI.indentLevel++;
                            foreach (SpriteData spriteData in sceneToSingleSprites[sceneAsset])
                            {
                                DrawSpriteDataField(spriteData);
                            }

                            SpriteAuditorUtility.DrawDefaultSelectionOptions(sceneToSingleSprites[sceneAsset]
                                                                             .Select(spriteData => spriteData.Sprite).Cast <Object>().ToList());
                            EditorGUI.indentLevel--;
                        }
                        EditorGUILayout.EndVertical();
                    }

                    if (sceneToAtlasToUsedSprites.ContainsKey(sceneAsset))
                    {
                        foreach (var atlasToUSedSprites in sceneToAtlasToUsedSprites[sceneAsset])
                        {
                            EditorGUILayout.BeginVertical("Box");

                            {
                                if (SpriteAuditorGUIUtility.DrawObjectFoldout(atlasToUSedSprites.Key,
                                                                              $"{VisualizationType.Scene.ToString()}_{atlasToUSedSprites.Key}"))
                                {
                                    EditorGUI.indentLevel++;
                                    foreach (SpriteData spriteData in sceneToAtlasToUsedSprites[sceneAsset][
                                                 atlasToUSedSprites.Key])
                                    {
                                        DrawSpriteDataField(spriteData);
                                    }

                                    SpriteAuditorUtility.DrawDefaultSelectionOptions(
                                        sceneToAtlasToUsedSprites[sceneAsset][atlasToUSedSprites.Key]
                                        .Select(spriteData => spriteData.Sprite).Cast <Object>().ToList());
                                    EditorGUI.indentLevel--;
                                }
                            }
                            EditorGUILayout.EndVertical();
                        }
                    }

                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndVertical();
            }
        }