private void OnEnable()
 {
     EditorApplication.playModeStateChanged += OnPlayModeChanged;
     SpriteAuditorUtility.SetMemoryDataDirty();
     SpriteAuditorUtility.SetResultViewDirty();
     SpriteAuditorUtility.SetSizeCheckThreshold(spriteUsageSizeThreshold);
 }
 private void OnEnable()
 {
     EditorApplication.playModeStateChanged += OnPlayModeChanged;
     SpriteAuditorUtility.SetMemoryDataDirty();
     SpriteAuditorUtility.SetResultViewDirty();
     isOpen = true;
 }
        private void OnPlayModeChanged(PlayModeStateChange playMode)
        {
            switch (playMode)
            {
            case PlayModeStateChange.EnteredPlayMode:
            {
                StartRecording();
                break;
            }

            case PlayModeStateChange.ExitingPlayMode:
            {
                if (isRecording)
                {
                    StopRecording();
                    StoreDatabase();
                }

                break;
            }

            case PlayModeStateChange.EnteredEditMode:
                SpriteAuditorUtility.SetResultViewDirty();
                break;
            }
        }
Beispiel #4
0
 public override void DrawFilterOptions()
 {
     EditorGUI.BeginChangeCheck();
     currentFilter = (Filter)EditorGUILayout.EnumFlagsField("Filter", currentFilter);
     if (EditorGUI.EndChangeCheck())
     {
         SpriteAuditorUtility.SetResultViewDirty();
     }
 }
Beispiel #5
0
        private SpriteData GetOrCreateSpriteData(Sprite sprite)
        {
            if (TryGetSpriteDataBySprite(sprite, out SpriteData spriteData))
            {
                return(spriteData);
            }

            spriteData = new SpriteData(sprite);
            spritesData.Add(spriteData);
            SpriteAuditorUtility.SetResultViewDirty();
            return(spriteData);
        }
Beispiel #6
0
        private SpriteUseData GetOrCreateSpriteUsageData(GameObject instance, string usagePath)
        {
            int instanceID = instance.GetInstanceID();

            if (TryGetSpriteUsageData(instance, instanceID, usagePath, out SpriteUseData spriteUseData))
            {
                return(spriteUseData);
            }

            spriteUseData = new SpriteUseData(instance, instanceID, usagePath);
            usages.Add(spriteUseData);
            SpriteAuditorUtility.SetResultViewDirty();
            return(spriteUseData);
        }
Beispiel #7
0
 private void ReportScene(Scene scene)
 {
     if (scene.buildIndex == -1 || string.IsNullOrEmpty(scene.path))
     {
         spriteUsageFlags |= SpriteUsageFlags.UsedOnDontDestroyOrUnknowScene;
     }
     else
     {
         if (scenesPath.Add(scene.path))
         {
             SpriteAuditorUtility.SetResultViewDirty();
         }
     }
 }
Beispiel #8
0
        public void ReportPath(string usagePath, Scene targetScene)
        {
            string targetScenePath = targetScene.path;
            string storagePath     = $"{targetScenePath}{PATH_SEPARATOR}{usagePath}";

            if (paths.Count == 0)
            {
                firstPath = storagePath;
            }
            if (paths.Add(storagePath))
            {
                SpriteAuditorUtility.SetResultViewDirty();
            }
        }
        private void DrawResults()
        {
            if (SpriteAuditorUtility.IsMemoryDataDirty)
            {
                LoadOrCreateAtlasResult();
            }

            if (SpriteDatabase == null)
            {
                return;
            }

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Results", EditorStyles.toolbarDropDown);
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginHorizontal("Box");
            EditorGUI.BeginChangeCheck();
            visualizationType =
                (VisualizationType)GUILayout.SelectionGrid((int)visualizationType, VISUALIZATION_NAMES, 3,
                                                           EditorStyles.radioButton);
            if (EditorGUI.EndChangeCheck())
            {
                CreateResultViewByVisualizationType();
                SpriteAuditorUtility.SetResultViewDirty();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal("Box");

            ResultView.DrawFilterOptions();

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            if (SpriteAuditorUtility.IsReferencesDirty)
            {
                AtlasCacheUtility.ClearAtlasCache();
                ResultView.GenerateResults(SpriteDatabase);
                SpriteAuditorUtility.SetResultViewUpdated();
            }

            ResultView.DrawResults(SpriteDatabase);

            EditorGUILayout.EndVertical();
        }
        private void DrawResults()
        {
            if (SpriteDatabase == null)
            {
                return;
            }

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Results", EditorStyles.toolbarDropDown);
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginHorizontal("Box");
            EditorGUI.BeginChangeCheck();
            visualizationType =
                (VisualizationType)GUILayout.SelectionGrid((int)visualizationType, VISUALIZATION_NAMES, 3,
                                                           EditorStyles.radioButton);
            if (EditorGUI.EndChangeCheck())
            {
                CreateResultViewByVisualizationType();
                SpriteAuditorUtility.ClearSelection();
                SpriteAuditorUtility.SetResultViewDirty();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal("Box");

            ResultView.DrawFilterOptions();

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            DrawSearch();
            SpriteAuditorBatchAction.DrawBatchActions();
            ResultView.DrawResults(SpriteDatabase);

            EditorGUILayout.EndVertical();
        }
 private void ClearCache()
 {
     EditorPrefs.DeleteKey(ATLAS_AUDITOR_STORAGE_KEY);
     cachedSpriteDatabase = null;
     SpriteAuditorUtility.SetResultViewDirty();
 }
 public static void ScriptsReloaded()
 {
     SpriteAuditorUtility.SetMemoryDataDirty();
     SpriteAuditorUtility.SetResultViewDirty();
 }