com.wallstop-studios.unity-helpers 2.0.0-rc74.5 → 2.0.0-rc74.6

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.
@@ -5,11 +5,13 @@
5
5
  using System.Collections.Generic;
6
6
  using System.IO;
7
7
  using System.Linq;
8
+ using System.Text.RegularExpressions;
8
9
  using System.Threading.Tasks;
9
10
  using UnityEditor;
10
11
  using UnityEngine;
11
12
  using Core.Extension;
12
13
  using CustomEditors;
14
+ using Microsoft.CodeAnalysis.CSharp.Syntax;
13
15
  using Object = UnityEngine.Object;
14
16
 
15
17
  public sealed class SpriteCropper : EditorWindow
@@ -33,6 +35,9 @@
33
35
  [SerializeField]
34
36
  private List<Object> _inputDirectories = new();
35
37
 
38
+ [SerializeField]
39
+ private string _spriteNameRegex = ".*";
40
+
36
41
  [SerializeField]
37
42
  private bool _onlyNecessary;
38
43
 
@@ -56,6 +61,9 @@
56
61
  private SerializedProperty _rightPaddingProperty;
57
62
  private SerializedProperty _topPaddingProperty;
58
63
  private SerializedProperty _bottomPaddingProperty;
64
+ private SerializedProperty _spriteNameRegexProperty;
65
+
66
+ private Regex _regex;
59
67
 
60
68
  [MenuItem("Tools/Wallstop Studios/Unity Helpers/" + Name)]
61
69
  private static void ShowWindow() => GetWindow<SpriteCropper>(Name);
@@ -69,6 +77,7 @@
69
77
  _rightPaddingProperty = _serializedObject.FindProperty(nameof(_rightPadding));
70
78
  _topPaddingProperty = _serializedObject.FindProperty(nameof(_topPadding));
71
79
  _bottomPaddingProperty = _serializedObject.FindProperty(nameof(_bottomPadding));
80
+ _spriteNameRegexProperty = _serializedObject.FindProperty(nameof(_spriteNameRegex));
72
81
  }
73
82
 
74
83
  private void OnGUI()
@@ -79,6 +88,7 @@
79
88
  _inputDirectoriesProperty,
80
89
  nameof(SpriteCropper)
81
90
  );
91
+ EditorGUILayout.PropertyField(_spriteNameRegexProperty, true);
82
92
  EditorGUILayout.PropertyField(_onlyNecessaryProperty, true);
83
93
  EditorGUILayout.PropertyField(_leftPaddingProperty, true);
84
94
  EditorGUILayout.PropertyField(_rightPaddingProperty, true);
@@ -88,6 +98,9 @@
88
98
 
89
99
  if (GUILayout.Button("Find Sprites To Process"))
90
100
  {
101
+ _regex = !string.IsNullOrWhiteSpace(_spriteNameRegex)
102
+ ? new Regex(_spriteNameRegex)
103
+ : null;
91
104
  FindFilesToProcess();
92
105
  }
93
106
 
@@ -146,6 +159,13 @@
146
159
  {
147
160
  continue;
148
161
  }
162
+
163
+ string fileName = Path.GetFileNameWithoutExtension(file);
164
+ if (_regex != null && !_regex.IsMatch(fileName))
165
+ {
166
+ continue;
167
+ }
168
+
149
169
  _filesToProcess.Add(file);
150
170
  }
151
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc74.5",
3
+ "version": "2.0.0-rc74.6",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -59,5 +59,6 @@
59
59
 
60
60
 
61
61
 
62
+
62
63
 
63
64