com.wallstop-studios.unity-helpers 2.0.0-rc76.5 → 2.0.0-rc76.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.
@@ -620,7 +620,10 @@
620
620
  }
621
621
  }
622
622
  }
623
- catch { }
623
+ catch
624
+ {
625
+ // Swalllow
626
+ }
624
627
  }
625
628
  if (!Directory.Exists(initialBrowsePath))
626
629
  {
@@ -38,9 +38,6 @@
38
38
  SerializedProperty folderPathProp = property.FindPropertyRelative(
39
39
  nameof(SourceFolderEntry.folderPath)
40
40
  );
41
- SerializedProperty regexesProp = property.FindPropertyRelative(
42
- nameof(SourceFolderEntry.regexes)
43
- );
44
41
 
45
42
  Rect folderPathLabelRect = new(
46
43
  startX,
@@ -153,48 +150,63 @@
153
150
 
154
151
  if (RegexesFoldoutState[regexesFoldoutKey])
155
152
  {
156
- int listElementIndentLvl = EditorGUI.indentLevel;
157
- EditorGUI.indentLevel++;
158
- float regexStartX = startX + 15f;
159
- float regexAvailableWidth = availableWidth - 15f;
160
- Rect sizeFieldRect = new(
161
- regexStartX,
162
- currentY,
163
- regexAvailableWidth,
164
- EditorGUIUtility.singleLineHeight
153
+ SerializedProperty regexesProp = property.FindPropertyRelative(
154
+ nameof(SourceFolderEntry.regexes)
165
155
  );
166
-
167
- EditorGUI.BeginChangeCheck();
168
- int newSize = EditorGUI.IntField(sizeFieldRect, "Size", regexesProp.arraySize);
169
- if (EditorGUI.EndChangeCheck())
170
- {
171
- newSize = Mathf.Max(0, newSize);
172
- regexesProp.arraySize = newSize;
173
- }
174
- currentY += sizeFieldRect.height + EditorGUIUtility.standardVerticalSpacing;
156
+ float regexStartX = startX + 15f;
157
+ float regexWidth = availableWidth - 15f;
175
158
 
176
159
  for (int i = 0; i < regexesProp.arraySize; i++)
177
160
  {
178
- SerializedProperty elementProp = regexesProp.GetArrayElementAtIndex(i);
179
- Rect elementRect = new(
161
+ SerializedProperty elemProp = regexesProp.GetArrayElementAtIndex(i);
162
+ Rect fieldRect = new(
180
163
  regexStartX,
181
164
  currentY,
182
- regexAvailableWidth,
165
+ regexWidth - 25f,
183
166
  EditorGUIUtility.singleLineHeight
184
167
  );
185
168
  EditorGUI.BeginChangeCheck();
186
- string newStringValue = EditorGUI.TextField(
187
- elementRect,
188
- $"Element {i}",
189
- elementProp.stringValue
169
+ string newVal = EditorGUI.TextField(
170
+ fieldRect,
171
+ $"Regex {i}:",
172
+ elemProp.stringValue
190
173
  );
191
174
  if (EditorGUI.EndChangeCheck())
192
175
  {
193
- elementProp.stringValue = newStringValue;
176
+ elemProp.stringValue = newVal;
177
+ }
178
+
179
+ Rect remRect = new(
180
+ fieldRect.xMax + 4f,
181
+ currentY,
182
+ 25f,
183
+ EditorGUIUtility.singleLineHeight
184
+ );
185
+ if (GUI.Button(remRect, "–"))
186
+ {
187
+ regexesProp.DeleteArrayElementAtIndex(i);
188
+ property.serializedObject.ApplyModifiedProperties();
194
189
  }
195
- currentY += elementRect.height + EditorGUIUtility.standardVerticalSpacing;
190
+
191
+ currentY +=
192
+ EditorGUIUtility.singleLineHeight
193
+ + EditorGUIUtility.standardVerticalSpacing;
194
+ }
195
+
196
+ Rect addRect = new(
197
+ regexStartX,
198
+ currentY,
199
+ regexWidth,
200
+ EditorGUIUtility.singleLineHeight
201
+ );
202
+
203
+ if (GUI.Button(addRect, "+ Add Regex"))
204
+ {
205
+ int idx = regexesProp.arraySize;
206
+ regexesProp.InsertArrayElementAtIndex(idx);
207
+ regexesProp.GetArrayElementAtIndex(idx).stringValue = string.Empty;
208
+ property.serializedObject.ApplyModifiedProperties();
196
209
  }
197
- EditorGUI.indentLevel = listElementIndentLvl;
198
210
  }
199
211
  EditorGUI.indentLevel = originalIndent;
200
212
  }
@@ -16,6 +16,8 @@
16
16
 
17
17
  public sealed class ScriptableSpriteAtlasEditor : EditorWindow
18
18
  {
19
+ private readonly Dictionary<ScriptableSpriteAtlas, SerializedObject> _serializedConfigs =
20
+ new();
19
21
  private List<ScriptableSpriteAtlas> _atlasConfigs = new();
20
22
  private Vector2 _scrollPosition;
21
23
 
@@ -58,6 +60,7 @@
58
60
  Dictionary<ScriptableSpriteAtlas, ScanResult> existingScanCache = new(
59
61
  _scanResultsCache
60
62
  );
63
+ _serializedConfigs.Clear();
61
64
  _scanResultsCache.Clear();
62
65
 
63
66
  string[] guids = AssetDatabase.FindAssets("t:ScriptableSpriteAtlas");
@@ -78,6 +81,7 @@
78
81
  {
79
82
  _scanResultsCache[config] = new ScanResult();
80
83
  }
84
+ _serializedConfigs.TryAdd(config, newConfig => new SerializedObject(newConfig));
81
85
  _foldoutStates.TryAdd(config, true);
82
86
  }
83
87
  }
@@ -155,7 +159,10 @@
155
159
  if (_foldoutStates[config])
156
160
  {
157
161
  using EditorGUI.IndentLevelScope indentScope = new();
158
- SerializedObject serializedConfig = new(config);
162
+ SerializedObject serializedConfig = _serializedConfigs.GetOrAdd(
163
+ config,
164
+ newConfig => new SerializedObject(newConfig)
165
+ );
159
166
  serializedConfig.Update();
160
167
  EditorGUI.BeginChangeCheck();
161
168
 
@@ -169,6 +176,7 @@
169
176
  );
170
177
  if (EditorGUI.EndChangeCheck())
171
178
  {
179
+ serializedConfig.ApplyModifiedProperties();
172
180
  if (
173
181
  !string.IsNullOrWhiteSpace(newAssetName)
174
182
  && newAssetName != currentAssetName