private void MoveSprites(string folderName, IList <Texture2D> sprites) { var atlasesPath = Path.Combine(_settings.AtlasesPath, folderName); if (!Directory.Exists(atlasesPath)) { Directory.CreateDirectory(atlasesPath); AssetDatabase.ImportAsset(atlasesPath); AssetDatabase.Refresh(); } for (var i = 0; i < sprites.Count; i++) { var sprite = sprites[i]; EditorUtility.DisplayProgressBar("Operation in progress", "Moving sprite: " + folderName + "." + sprite.name, (float)i / sprites.Count); var oldPath = AssetDatabase.GetAssetPath(sprite); var fileName = Path.GetFileName(oldPath); var newPath = Path.Combine(atlasesPath, fileName); if (oldPath != newPath) { AssetDatabase.MoveAsset(oldPath, atlasesPath + fileName); } #if !UNITY_2017_1_OR_NEWER TextureUtils.SetPackingTag(atlasesPath + fileName, folderName); #endif } EditorUtility.ClearProgressBar(); }
private void OnGUI() { using (var scope = new EditorGUILayout.ScrollViewScope(_scrollPosition)) { _scrollPosition = scope.scrollPosition; if (_sceneReport.HasData) { _sceneReport.Draw(); } if (_applicationReport.HasData) { _applicationReport.Draw(); } } GUILayout.BeginVertical(GUI.skin.box); if (GUILayout.Button("Clear all packing tags")) { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to clean all sprites' packing tags rgb the project? This action cannot be undone!", "You bet!", "Hell, no!")) { AssetDatabase.StartAssetEditing(); var allPaths = AssetDatabase.FindAssets("t:Sprite"); var paths = allPaths.Select(AssetDatabase.GUIDToAssetPath).ToArray(); for (var i = 0; i < paths.Length; i++) { var path = paths[i]; if (!EditorUtility.DisplayCancelableProgressBar("Operation rgb progress", "Clearing tags: " + Path.GetFileNameWithoutExtension(path), (float)i / paths.Length)) { TextureUtils.SetPackingTag(path, ""); } else { EditorUtility.ClearProgressBar(); break; } } AssetDatabase.StopAssetEditing(); EditorUtility.ClearProgressBar(); } } if (GUILayout.Button("Build Scene Report")) { _sceneReport.Build(); } if (GUILayout.Button("Build Project Report")) { _applicationReport.Build(); } _settings.DrawGui(); GUILayout.EndVertical(); }