com.wallstop-studios.unity-helpers 2.0.0-rc73.1 → 2.0.0-rc73.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/Editor/AnimationCopier.cs +58 -50
  2. package/Editor/AnimationCreator.cs +17 -24
  3. package/Editor/AnimationEventEditor.cs +11 -23
  4. package/Editor/FitTextureSizeWindow.cs +9 -9
  5. package/Editor/PrefabChecker.cs +12 -18
  6. package/Editor/SpriteAtlasGenerator.cs +47 -66
  7. package/Editor/SpriteCropper.cs +157 -131
  8. package/Editor/SpriteSettingsApplier.cs +5 -3
  9. package/Editor/Utils/GUIIndentScope.cs +20 -0
  10. package/Editor/Utils/GUIIndentScope.cs.meta +3 -0
  11. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  12. package/Runtime/Core/DataStructure/QuadTree.cs +4 -4
  13. package/Runtime/Core/Extension/ColorExtensions.cs +5 -5
  14. package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
  15. package/Runtime/Core/Extension/UnityExtensions.cs +14 -14
  16. package/Runtime/Core/Helper/Helpers.cs +9 -9
  17. package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +31 -8
  18. package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +2 -2
  19. package/Runtime/Core/Helper/PathHelper.cs +15 -0
  20. package/Runtime/Core/Helper/PathHelper.cs.meta +3 -0
  21. package/Runtime/Core/Random/DotNetRandom.cs +1 -1
  22. package/Runtime/Core/Random/SplitMix64.cs +1 -1
  23. package/Runtime/Core/Random/SquirrelRandom.cs +7 -7
  24. package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
  25. package/Runtime/Core/Random/WyRandom.cs +1 -1
  26. package/Runtime/Tags/AttributeEffect.cs +1 -0
  27. package/Runtime/Tags/EffectHandler.cs +1 -1
  28. package/Runtime/UI/LayeredImage.cs +309 -161
  29. package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
  30. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  31. package/Runtime/Utils/TextureScale.cs +4 -4
  32. package/Styles/Elements/Progress/ArcedProgressBar.cs +345 -0
  33. package/Styles/Elements/Progress/ArcedProgressBar.cs.meta +3 -0
  34. package/Styles/Elements/Progress/CircularProgressBar.cs +307 -0
  35. package/Styles/Elements/Progress/CircularProgressBar.cs.meta +3 -0
  36. package/Styles/Elements/Progress/GlitchProgressBar.cs +416 -0
  37. package/Styles/Elements/Progress/GlitchProgressBar.cs.meta +3 -0
  38. package/Styles/Elements/Progress/LiquidProgressBar.cs +632 -0
  39. package/Styles/Elements/Progress/LiquidProgressBar.cs.meta +3 -0
  40. package/Styles/Elements/Progress/MarchingAntsProgressBar.cs +722 -0
  41. package/Styles/Elements/Progress/MarchingAntsProgressBar.cs.meta +3 -0
  42. package/Styles/Elements/Progress/RegularProgressBar.cs +405 -0
  43. package/Styles/Elements/Progress/RegularProgressBar.cs.meta +3 -0
  44. package/Styles/Elements/Progress/WigglyProgressBar.cs +837 -0
  45. package/Styles/Elements/Progress/WigglyProgressBar.cs.meta +3 -0
  46. package/Styles/Elements/Progress.meta +3 -0
  47. package/Styles/Elements.meta +3 -0
  48. package/Styles/USS/ArcedProgressBar.uss +19 -0
  49. package/Styles/USS/ArcedProgressBar.uss.meta +3 -0
  50. package/Styles/USS/CirclularProgressBar.uss +18 -0
  51. package/Styles/USS/CirclularProgressBar.uss.meta +3 -0
  52. package/Styles/USS/RegularProgressBar.uss +33 -0
  53. package/Styles/USS/RegularProgressBar.uss.meta +3 -0
  54. package/Styles/USS/WigglyProgressBar.uss +17 -0
  55. package/Styles/USS/WigglyProgressBar.uss.meta +3 -0
  56. package/Styles/USS.meta +3 -0
  57. package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef +17 -0
  58. package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef.meta +7 -0
  59. package/Styles.meta +3 -0
  60. package/package.json +10 -1
@@ -9,6 +9,7 @@
9
9
  using UnityEditor;
10
10
  using UnityEngine;
11
11
  using Core.Extension;
12
+ using Core.Helper;
12
13
 
13
14
  public sealed class AnimationCopierWindow : EditorWindow
14
15
  {
@@ -58,7 +59,7 @@
58
59
  public string DestinationRelativePath { get; set; }
59
60
  }
60
61
 
61
- [MenuItem("Tools/Wallstop Studios/Unity Helpers/Animation Copier Window", priority = -2)]
62
+ [MenuItem("Tools/Wallstop Studios/Unity Helpers/Animation Copier", priority = -2)]
62
63
  public static void ShowWindow()
63
64
  {
64
65
  GetWindow<AnimationCopierWindow>("Animation Copier");
@@ -185,7 +186,7 @@
185
186
  if (newRelPath != null)
186
187
  {
187
188
  relativePath = newRelPath;
188
- fullPath = selectedPath.Replace(Path.DirectorySeparatorChar, '/');
189
+ fullPath = selectedPath.SanitizePath();
189
190
  EditorPrefs.SetString(prefKey, relativePath);
190
191
  this.Log($"{label} set to: {relativePath}");
191
192
  ValidatePaths();
@@ -436,7 +437,10 @@
436
437
  string sourceRelPath = AssetDatabase.GUIDToAssetPath(guid);
437
438
  if (
438
439
  string.IsNullOrWhiteSpace(sourceRelPath)
439
- || !sourceRelPath.StartsWith(_animationSourcePathRelative)
440
+ || !sourceRelPath.StartsWith(
441
+ _animationSourcePathRelative,
442
+ StringComparison.OrdinalIgnoreCase
443
+ )
440
444
  )
441
445
  {
442
446
  continue;
@@ -460,7 +464,7 @@
460
464
  FileName = Path.GetFileName(sourceRelPath),
461
465
  RelativeDirectory = GetRelativeSubPath(
462
466
  _animationSourcePathRelative,
463
- directoryName.Replace(Path.DirectorySeparatorChar, '/')
467
+ directoryName.SanitizePath()
464
468
  ),
465
469
  Hash = CalculateFileHash(sourceFullPath),
466
470
  };
@@ -469,7 +473,7 @@
469
473
  fileInfo.RelativeDirectory,
470
474
  fileInfo.FileName
471
475
  )
472
- .Replace(Path.DirectorySeparatorChar, '/');
476
+ .SanitizePath();
473
477
  _sourceAnimations.Add(fileInfo);
474
478
 
475
479
  EditorUtility.DisplayProgressBar(
@@ -505,7 +509,10 @@
505
509
  else
506
510
  {
507
511
  string destHash = CalculateFileHash(destFullPath);
508
- if (string.IsNullOrEmpty(sourceInfo.Hash) || string.IsNullOrEmpty(destHash))
512
+ if (
513
+ string.IsNullOrWhiteSpace(sourceInfo.Hash)
514
+ || string.IsNullOrWhiteSpace(destHash)
515
+ )
509
516
  {
510
517
  this.LogWarn(
511
518
  $"Could not compare '{sourceInfo.FileName}' due to hashing error. Treating as 'Changed'."
@@ -593,8 +600,32 @@
593
600
 
594
601
  int successCount = 0;
595
602
  int errorCount = 0;
596
- AssetDatabase.StartAssetEditing();
603
+ foreach (AnimationFileInfo animInfo in animationsToCopy)
604
+ {
605
+ string destinationAssetPath = animInfo.DestinationRelativePath;
606
+ string destDirectory = Path.GetDirectoryName(destinationAssetPath).SanitizePath();
607
+
608
+ if (
609
+ string.IsNullOrWhiteSpace(destDirectory)
610
+ || AssetDatabase.IsValidFolder(destDirectory)
611
+ )
612
+ {
613
+ continue;
614
+ }
597
615
 
616
+ try
617
+ {
618
+ EnsureDirectoryExists(destDirectory);
619
+ }
620
+ catch (Exception ex)
621
+ {
622
+ this.LogError(
623
+ $"Failed to create destination directory '{destDirectory}' for animation '{animInfo.FileName}'. Error: {ex.Message}. Skipping."
624
+ );
625
+ }
626
+ }
627
+
628
+ AssetDatabase.StartAssetEditing();
598
629
  try
599
630
  {
600
631
  for (int i = 0; i < animationsToCopy.Count; i++)
@@ -615,27 +646,6 @@
615
646
 
616
647
  string sourceAssetPath = animInfo.RelativePath;
617
648
  string destinationAssetPath = animInfo.DestinationRelativePath;
618
- string destDirectory = Path.GetDirectoryName(destinationAssetPath);
619
-
620
- if (
621
- !string.IsNullOrEmpty(destDirectory)
622
- && !AssetDatabase.IsValidFolder(destDirectory)
623
- )
624
- {
625
- try
626
- {
627
- EnsureDirectoryExists(destDirectory);
628
- }
629
- catch (Exception ex)
630
- {
631
- this.LogError(
632
- $"Failed to create destination directory '{destDirectory}' for animation '{animInfo.FileName}'. Error: {ex.Message}. Skipping."
633
- );
634
- errorCount++;
635
- continue;
636
- }
637
- }
638
-
639
649
  bool copySuccessful = AssetDatabase.CopyAsset(
640
650
  sourceAssetPath,
641
651
  destinationAssetPath
@@ -784,7 +794,7 @@
784
794
  return null;
785
795
  }
786
796
 
787
- fullPath = fullPath.Replace(Path.DirectorySeparatorChar, '/');
797
+ fullPath = fullPath.SanitizePath();
788
798
  if (
789
799
  fullPath.EndsWith("/Assets", StringComparison.OrdinalIgnoreCase)
790
800
  && Path.GetFileName(fullPath).Equals("Assets", StringComparison.OrdinalIgnoreCase)
@@ -793,7 +803,7 @@
793
803
  return "Assets";
794
804
  }
795
805
 
796
- string assetsPath = Application.dataPath.Replace(Path.DirectorySeparatorChar, '/');
806
+ string assetsPath = Application.dataPath.SanitizePath();
797
807
  if (fullPath.StartsWith(assetsPath, StringComparison.OrdinalIgnoreCase))
798
808
  {
799
809
  if (fullPath.Length == assetsPath.Length)
@@ -828,7 +838,7 @@
828
838
 
829
839
  if (relativePath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
830
840
  {
831
- return Application.dataPath.Replace(Path.DirectorySeparatorChar, '/');
841
+ return Application.dataPath.SanitizePath();
832
842
  }
833
843
 
834
844
  if (relativePath.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase))
@@ -837,7 +847,7 @@
837
847
  0,
838
848
  Application.dataPath.Length - "Assets".Length
839
849
  );
840
- return (projectRoot + relativePath).Replace(Path.DirectorySeparatorChar, '/');
850
+ return (projectRoot + relativePath).SanitizePath();
841
851
  }
842
852
  return null;
843
853
  }
@@ -866,28 +876,28 @@
866
876
  return string.Empty;
867
877
  }
868
878
 
869
- private static string CalculateFileHash(string filePath)
879
+ private string CalculateFileHash(string filePath)
870
880
  {
871
881
  try
872
882
  {
873
- using (MD5 md5 = MD5.Create())
874
- using (FileStream stream = File.OpenRead(filePath))
875
- {
876
- byte[] hashBytes = md5.ComputeHash(stream);
877
- return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
878
- }
883
+ using MD5 md5 = MD5.Create();
884
+ using FileStream stream = File.OpenRead(filePath);
885
+ byte[] hashBytes = md5.ComputeHash(stream);
886
+ return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
879
887
  }
880
888
  catch (IOException ioEx)
881
889
  {
882
- Debug.LogError(
883
- $"[AnimationCopierWindow] IO Error calculating hash for {filePath}: {ioEx.Message}"
890
+ this.LogError(
891
+ $"[AnimationCopierWindow] IO Error calculating hash for {filePath}.",
892
+ ioEx
884
893
  );
885
894
  return string.Empty;
886
895
  }
887
896
  catch (Exception ex)
888
897
  {
889
- Debug.LogError(
890
- $"[AnimationCopierWindow] Error calculating hash for {filePath}: {ex.Message}"
898
+ this.LogError(
899
+ $"[AnimationCopierWindow] Error calculating hash for {filePath}.",
900
+ ex
891
901
  );
892
902
  return string.Empty;
893
903
  }
@@ -899,6 +909,7 @@
899
909
  {
900
910
  return;
901
911
  }
912
+
902
913
  if (!relativeDirectoryPath.StartsWith("Assets/"))
903
914
  {
904
915
  if (relativeDirectoryPath.Equals("Assets", StringComparison.OrdinalIgnoreCase))
@@ -920,17 +931,15 @@
920
931
  return;
921
932
  }
922
933
 
923
- string parentPath = Path.GetDirectoryName(relativeDirectoryPath)
924
- ?.Replace(Path.DirectorySeparatorChar, '/');
925
-
934
+ string parentPath = Path.GetDirectoryName(relativeDirectoryPath).SanitizePath();
926
935
  if (
927
- string.IsNullOrEmpty(parentPath)
936
+ string.IsNullOrWhiteSpace(parentPath)
928
937
  || parentPath.Equals("Assets", StringComparison.OrdinalIgnoreCase)
929
938
  )
930
939
  {
931
940
  string folderNameToCreate = Path.GetFileName(relativeDirectoryPath);
932
941
  if (
933
- !string.IsNullOrEmpty(folderNameToCreate)
942
+ !string.IsNullOrWhiteSpace(folderNameToCreate)
934
943
  && !AssetDatabase.IsValidFolder(relativeDirectoryPath)
935
944
  )
936
945
  {
@@ -940,10 +949,9 @@
940
949
  }
941
950
 
942
951
  EnsureDirectoryExists(parentPath);
943
-
944
952
  string currentFolderName = Path.GetFileName(relativeDirectoryPath);
945
953
  if (
946
- !string.IsNullOrEmpty(currentFolderName)
954
+ !string.IsNullOrWhiteSpace(currentFolderName)
947
955
  && !AssetDatabase.IsValidFolder(relativeDirectoryPath)
948
956
  )
949
957
  {
@@ -7,8 +7,10 @@
7
7
  using System.IO;
8
8
  using System.Linq;
9
9
  using System.Text.RegularExpressions;
10
+ using Core.Helper;
10
11
  using UnityEditor;
11
12
  using UnityEngine;
13
+ using Utils;
12
14
  using Object = UnityEngine.Object;
13
15
 
14
16
  [Serializable]
@@ -25,6 +27,8 @@
25
27
 
26
28
  public sealed class AnimationCreatorWindow : EditorWindow
27
29
  {
30
+ private static readonly char[] WhiteSpaceSplitters = { ' ', '\t', '\n', '\r' };
31
+
28
32
  private SerializedObject _serializedObject;
29
33
  private SerializedProperty _animationDataProp;
30
34
  private SerializedProperty _animationSourcesProp;
@@ -87,7 +91,7 @@
87
91
  else if (
88
92
  _animationSourcesProp.arraySize == 0
89
93
  || _animationSourcesProp.FindPropertyRelative("Array.size").intValue == 0
90
- || animationSources.TrueForAll(s => s == null)
94
+ || animationSources.TrueForAll(Objects.Null)
91
95
  )
92
96
  {
93
97
  EditorGUILayout.HelpBox(
@@ -136,7 +140,7 @@
136
140
  return;
137
141
  }
138
142
 
139
- absolutePath = absolutePath.Replace("\\", "/");
143
+ absolutePath = absolutePath.SanitizePath();
140
144
  if (absolutePath.StartsWith(Application.dataPath, StringComparison.OrdinalIgnoreCase))
141
145
  {
142
146
  string relativePath =
@@ -205,10 +209,7 @@
205
209
  int listSize = _animationDataProp.arraySize;
206
210
  string[] searchTerms = string.IsNullOrWhiteSpace(_searchString)
207
211
  ? Array.Empty<string>()
208
- : _searchString.Split(
209
- new[] { ' ', '\t', '\n', '\r' },
210
- StringSplitOptions.RemoveEmptyEntries
211
- );
212
+ : _searchString.Split(WhiteSpaceSplitters, StringSplitOptions.RemoveEmptyEntries);
212
213
 
213
214
  List<int> matchingIndices = new();
214
215
  for (int i = 0; i < listSize; ++i)
@@ -245,7 +246,7 @@
245
246
 
246
247
  if (_animationDataIsExpanded)
247
248
  {
248
- EditorGUI.indentLevel++;
249
+ using GUIIndentScope indent = new();
249
250
  if (matchCount > 0)
250
251
  {
251
252
  foreach (int index in matchingIndices)
@@ -273,8 +274,6 @@
273
274
  MessageType.Info
274
275
  );
275
276
  }
276
-
277
- EditorGUI.indentLevel--;
278
277
  }
279
278
  }
280
279
 
@@ -439,14 +438,14 @@
439
438
  }
440
439
 
441
440
  EditorGUILayout.Space();
442
- using (new EditorGUI.DisabledScope(animationData == null || animationData.Count == 0))
441
+ using (new EditorGUI.DisabledScope(animationData is not { Count: > 0 }))
443
442
  {
444
443
  if (GUILayout.Button("Create Animations"))
445
444
  {
446
445
  CreateAnimations();
447
446
  }
448
447
  }
449
- if (animationData == null || animationData.Count == 0)
448
+ if (animationData is not { Count: > 0 })
450
449
  {
451
450
  EditorGUILayout.HelpBox(
452
451
  "Add Animation Data entries before creating.",
@@ -457,7 +456,7 @@
457
456
 
458
457
  private void CreateAnimations()
459
458
  {
460
- if (animationData is not { Count: not 0 })
459
+ if (animationData is not { Count: > 0 })
461
460
  {
462
461
  this.LogError($"No animation data to create.");
463
462
  return;
@@ -532,7 +531,7 @@
532
531
  }
533
532
 
534
533
  List<Sprite> frames = data.frames;
535
- if (frames is not { Count: not 0 })
534
+ if (frames is not { Count: > 0 })
536
535
  {
537
536
  this.LogWarn(
538
537
  $"Ignoring animation '{animationName}' because it has no frames."
@@ -596,7 +595,7 @@
596
595
 
597
596
  string firstFramePath = AssetDatabase.GetAssetPath(validFrames[0]);
598
597
  string assetPath =
599
- Path.GetDirectoryName(firstFramePath)?.Replace("\\", "/") ?? "Assets";
598
+ Path.GetDirectoryName(firstFramePath).SanitizePath() ?? "Assets";
600
599
  if (!assetPath.EndsWith("/"))
601
600
  {
602
601
  assetPath += "/";
@@ -659,7 +658,7 @@
659
658
  _matchedSpriteCount = 0;
660
659
  _unmatchedSpriteCount = 0;
661
660
 
662
- if (animationSources is not { Count: not 0 } || _compiledRegex == null)
661
+ if (animationSources is not { Count: > 0 } || _compiledRegex == null)
663
662
  {
664
663
  if (_compiledRegex == null && !string.IsNullOrWhiteSpace(spriteNameRegex))
665
664
  {
@@ -667,7 +666,7 @@
667
666
  $"Cannot find sprites, regex pattern '{spriteNameRegex}' is invalid."
668
667
  );
669
668
  }
670
- else if (animationSources is not { Count: not 0 })
669
+ else if (animationSources is not { Count: > 0 })
671
670
  {
672
671
  this.LogWarn($"Cannot find sprites, no animation sources specified.");
673
672
  }
@@ -675,13 +674,8 @@
675
674
  }
676
675
 
677
676
  List<string> searchPaths = new();
678
- foreach (Object source in animationSources)
677
+ foreach (Object source in animationSources.Where(Objects.NotNull))
679
678
  {
680
- if (source == null)
681
- {
682
- continue;
683
- }
684
-
685
679
  string path = AssetDatabase.GetAssetPath(source);
686
680
  if (!string.IsNullOrWhiteSpace(path) && AssetDatabase.IsValidFolder(path))
687
681
  {
@@ -781,8 +775,7 @@
781
775
  }
782
776
 
783
777
  string assetPath = AssetDatabase.GetAssetPath(sprite);
784
- string directoryPath =
785
- Path.GetDirectoryName(assetPath)?.Replace("\\", "/") ?? "";
778
+ string directoryPath = Path.GetDirectoryName(assetPath).SanitizePath() ?? "";
786
779
  string frameName = sprite.name;
787
780
 
788
781
  int splitIndex = frameName.LastIndexOf('_');
@@ -9,6 +9,7 @@
9
9
  using UnityEngine;
10
10
  using Core.Attributes;
11
11
  using Core.Helper;
12
+ using Utils;
12
13
  using WallstopStudios.UnityHelpers.Utils;
13
14
 
14
15
  // https://gist.githubusercontent.com/yujen/5e1cd78e2a341260b38029de08a449da/raw/ac60c1002e0e14375de5b2b0a167af00df3f74b4/SeniaAnimationEventEditor.cs
@@ -172,16 +173,15 @@
172
173
 
173
174
  DrawSpritePreview(item);
174
175
 
175
- EditorGUI.indentLevel++;
176
- RenderAnimationEventItem(item, frame, frameRate);
177
-
178
- if (i != stateCopy.Count - 1)
176
+ using (new GUIIndentScope())
179
177
  {
180
- DrawGuiLine(height: 3, color: new Color(0f, 1f, 0.3f, 1f));
181
- EditorGUILayout.Space();
178
+ RenderAnimationEventItem(item, frame, frameRate);
179
+ if (i != stateCopy.Count - 1)
180
+ {
181
+ DrawGuiLine(height: 3, color: new Color(0f, 1f, 0.3f, 1f));
182
+ EditorGUILayout.Space();
183
+ }
182
184
  }
183
-
184
- EditorGUI.indentLevel--;
185
185
  }
186
186
 
187
187
  EditorGUILayout.EndScrollView();
@@ -320,8 +320,7 @@
320
320
  private void RenderAnimationEventItem(AnimationEventItem item, int frame, float frameRate)
321
321
  {
322
322
  int index = _state.IndexOf(item);
323
- EditorGUILayout.BeginHorizontal();
324
- try
323
+ using (new GUIHorizontalScope())
325
324
  {
326
325
  if (
327
326
  1 <= index
@@ -369,10 +368,6 @@
369
368
  return;
370
369
  }
371
370
  }
372
- finally
373
- {
374
- EditorGUILayout.EndHorizontal();
375
- }
376
371
 
377
372
  IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> lookup = FilterLookup(item);
378
373
 
@@ -541,7 +536,7 @@
541
536
  ParameterInfo[] arrayParameterInfo = item.selectedMethod.GetParameters();
542
537
  if (arrayParameterInfo.Length == 1)
543
538
  {
544
- EditorGUI.indentLevel++;
539
+ using GUIIndentScope indent = new();
545
540
 
546
541
  Type paramType = arrayParameterInfo[0].ParameterType;
547
542
  if (paramType == typeof(int))
@@ -602,8 +597,6 @@
602
597
  true
603
598
  );
604
599
  }
605
-
606
- EditorGUI.indentLevel--;
607
600
  }
608
601
  }
609
602
 
@@ -686,8 +679,7 @@
686
679
  }
687
680
  else if (!item.isTextureReadable && !string.IsNullOrEmpty(spriteName))
688
681
  {
689
- EditorGUILayout.BeginHorizontal();
690
- try
682
+ using (new GUIHorizontalScope())
691
683
  {
692
684
  GUILayout.Label($"Sprite '{spriteName}' required \"Read/Write\" enabled");
693
685
  if (item.sprite != null && GUILayout.Button("Fix"))
@@ -711,10 +703,6 @@
711
703
  EditorUtility.SetDirty(item.sprite);
712
704
  }
713
705
  }
714
- finally
715
- {
716
- EditorGUILayout.EndHorizontal();
717
- }
718
706
  }
719
707
  else if (item.isInvalidTextureRect && !string.IsNullOrEmpty(spriteName))
720
708
  {
@@ -40,7 +40,7 @@
40
40
  nameof(_textureSourcePaths)
41
41
  );
42
42
 
43
- if (_textureSourcePaths != null && _textureSourcePaths.Count != 0)
43
+ if (_textureSourcePaths is { Count: > 0 })
44
44
  {
45
45
  return;
46
46
  }
@@ -336,6 +336,14 @@
336
336
  _ = updatedImporters.Remove(textureImporter);
337
337
  }
338
338
  }
339
+ }
340
+ finally
341
+ {
342
+ if (applyChanges)
343
+ {
344
+ AssetDatabase.StopAssetEditing();
345
+ }
346
+ EditorUtility.ClearProgressBar();
339
347
 
340
348
  if (applyChanges)
341
349
  {
@@ -356,14 +364,6 @@
356
364
  }
357
365
  }
358
366
  }
359
- finally
360
- {
361
- if (applyChanges)
362
- {
363
- AssetDatabase.StopAssetEditing();
364
- }
365
- EditorUtility.ClearProgressBar();
366
- }
367
367
  return changedCount;
368
368
  }
369
369
  }
@@ -12,6 +12,7 @@
12
12
  using Core.Attributes;
13
13
  using Core.Extension;
14
14
  using Core.Helper;
15
+ using Utils;
15
16
  using WallstopStudios.UnityHelpers.Utils;
16
17
  using Object = UnityEngine.Object;
17
18
 
@@ -148,23 +149,16 @@
148
149
  GUI.enabled = wasEnabled && _checkNullObjectReferences;
149
150
  try
150
151
  {
151
- EditorGUI.indentLevel++;
152
- try
153
- {
154
- DrawAndAlign(
155
- new GUIContent(
156
- "Only if [ValidateAssignment]",
157
- "Only report null object references if the field has the [ValidateAssignment] attribute."
158
- ),
159
- () => _onlyCheckNullObjectsWithAttribute,
160
- v => _onlyCheckNullObjectsWithAttribute = v,
161
- true
162
- );
163
- }
164
- finally
165
- {
166
- EditorGUI.indentLevel--;
167
- }
152
+ using GUIIndentScope indent = new();
153
+ DrawAndAlign(
154
+ new GUIContent(
155
+ "Only if [ValidateAssignment]",
156
+ "Only report null object references if the field has the [ValidateAssignment] attribute."
157
+ ),
158
+ () => _onlyCheckNullObjectsWithAttribute,
159
+ v => _onlyCheckNullObjectsWithAttribute = v,
160
+ true
161
+ );
168
162
  }
169
163
  finally
170
164
  {
@@ -374,7 +368,7 @@
374
368
 
375
369
  private void RunChecks()
376
370
  {
377
- if (_assetPaths == null || _assetPaths.Count == 0)
371
+ if (_assetPaths is not { Count: > 0 })
378
372
  {
379
373
  this.LogError($"No asset paths specified. Add folders containing prefabs.");
380
374
  return;