com.wallstop-studios.unity-helpers 2.0.0-rc73.16 → 2.0.0-rc73.18

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.
@@ -1,16 +1,229 @@
1
1
  namespace WallstopStudios.UnityHelpers.Editor.CustomEditors
2
2
  {
3
3
  #if UNITY_EDITOR
4
+ using System;
4
5
  using UnityEngine;
5
6
  using UnityEditor;
6
7
  using System.Collections.Generic;
7
8
  using System.Linq;
8
9
  using Core.Helper;
9
10
  using System.IO;
11
+ using Object = UnityEngine.Object;
10
12
 
11
13
  public static class PersistentDirectoryGUI
12
14
  {
13
- private static readonly Dictionary<string, bool> ContextFoldoutStates = new();
15
+ private static readonly Dictionary<string, bool> ContextFoldoutStates = new(
16
+ StringComparer.Ordinal
17
+ );
18
+
19
+ public static float DrawFrequentPathsWithEditorGUI(
20
+ Rect parentRect,
21
+ ref float currentY,
22
+ string toolName,
23
+ string contextKey,
24
+ Action<string> onPathClickedFromHistory,
25
+ bool allowExpansion = true,
26
+ int topN = 5,
27
+ string listLabel = "History:"
28
+ )
29
+ {
30
+ if (PersistentDirectorySettings.Instance == null)
31
+ {
32
+ return 0f;
33
+ }
34
+
35
+ if (onPathClickedFromHistory == null)
36
+ {
37
+ Debug.LogError(
38
+ "PersistentDirectoryGUI.DrawFrequentPathsWithEditorGUI: onPathClickedFromHistory callback cannot be null."
39
+ );
40
+ return 0f;
41
+ }
42
+
43
+ float startY = currentY;
44
+ float availableWidth = parentRect.width;
45
+ float startX = parentRect.x;
46
+
47
+ DirectoryUsageData[] topPaths = PersistentDirectorySettings.Instance.GetPaths(
48
+ toolName,
49
+ contextKey,
50
+ true,
51
+ topN
52
+ );
53
+
54
+ if (topPaths.Length <= 0)
55
+ {
56
+ return currentY - startY;
57
+ }
58
+
59
+ Rect historyLabelRect = new(
60
+ startX,
61
+ currentY,
62
+ availableWidth,
63
+ EditorGUIUtility.singleLineHeight
64
+ );
65
+ EditorGUI.LabelField(historyLabelRect, listLabel, EditorStyles.miniBoldLabel);
66
+ currentY += historyLabelRect.height;
67
+
68
+ foreach (DirectoryUsageData dirData in topPaths)
69
+ {
70
+ Rect historyButtonRect = new(
71
+ startX + 15f,
72
+ currentY,
73
+ availableWidth - 15f,
74
+ EditorGUIUtility.singleLineHeight
75
+ );
76
+ if (
77
+ GUI.Button(
78
+ historyButtonRect,
79
+ new GUIContent($"({dirData.count}) {dirData.path}", dirData.path),
80
+ EditorStyles.miniButtonLeft
81
+ )
82
+ )
83
+ {
84
+ onPathClickedFromHistory.Invoke(dirData.path);
85
+ }
86
+ currentY += historyButtonRect.height;
87
+ }
88
+
89
+ if (allowExpansion)
90
+ {
91
+ string foldoutKey = $"{toolName}/{contextKey}_AllPathsHistory_EditorGUI";
92
+ ContextFoldoutStates.TryAdd(foldoutKey, false);
93
+ DirectoryUsageData[] allPaths = PersistentDirectorySettings.Instance.GetPaths(
94
+ toolName,
95
+ contextKey,
96
+ false,
97
+ 0
98
+ );
99
+ if (allPaths.Length > topN)
100
+ {
101
+ Rect expansionFoldoutRect = new(
102
+ startX + 15f,
103
+ currentY,
104
+ availableWidth - 15f,
105
+ EditorGUIUtility.singleLineHeight
106
+ );
107
+ ContextFoldoutStates[foldoutKey] = EditorGUI.Foldout(
108
+ expansionFoldoutRect,
109
+ ContextFoldoutStates[foldoutKey],
110
+ "Show All History (" + allPaths.Length + ")",
111
+ true,
112
+ EditorStyles.foldout
113
+ );
114
+ currentY += expansionFoldoutRect.height;
115
+
116
+ if (ContextFoldoutStates[foldoutKey])
117
+ {
118
+ List<DirectoryUsageData> pathsNotAlreadyInTop = allPaths
119
+ .Skip(topN)
120
+ .ToList();
121
+ if (pathsNotAlreadyInTop.Any())
122
+ {
123
+ foreach (DirectoryUsageData dirData in pathsNotAlreadyInTop)
124
+ {
125
+ Rect moreHistoryButtonRect = new(
126
+ startX + 30f,
127
+ currentY,
128
+ availableWidth - 30f,
129
+ EditorGUIUtility.singleLineHeight
130
+ );
131
+ if (
132
+ GUI.Button(
133
+ moreHistoryButtonRect,
134
+ new GUIContent(
135
+ $"({dirData.count}) {dirData.path}",
136
+ dirData.path
137
+ ),
138
+ EditorStyles.miniButtonLeft
139
+ )
140
+ )
141
+ {
142
+ onPathClickedFromHistory.Invoke(dirData.path);
143
+ }
144
+ currentY += moreHistoryButtonRect.height;
145
+ }
146
+ }
147
+ else
148
+ {
149
+ Rect noMorePathsLabelRect = new(
150
+ startX + 30f,
151
+ currentY,
152
+ availableWidth - 30f,
153
+ EditorGUIUtility.singleLineHeight
154
+ );
155
+ EditorGUI.LabelField(
156
+ noMorePathsLabelRect,
157
+ "All paths already displayed.",
158
+ EditorStyles.centeredGreyMiniLabel
159
+ );
160
+ currentY += noMorePathsLabelRect.height;
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ currentY += EditorGUIUtility.standardVerticalSpacing;
167
+ return currentY - startY;
168
+ }
169
+
170
+ public static float GetDrawFrequentPathsHeightEditorGUI(
171
+ string toolName,
172
+ string contextKey,
173
+ bool allowExpansion = true,
174
+ int topN = 5
175
+ )
176
+ {
177
+ if (PersistentDirectorySettings.Instance == null)
178
+ {
179
+ return 0f;
180
+ }
181
+
182
+ float height = 0f;
183
+ DirectoryUsageData[] topPaths = PersistentDirectorySettings.Instance.GetPaths(
184
+ toolName,
185
+ contextKey,
186
+ true,
187
+ topN
188
+ );
189
+
190
+ if (topPaths.Length <= 0)
191
+ {
192
+ return height;
193
+ }
194
+
195
+ height +=
196
+ (topPaths.Length + 1)
197
+ * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
198
+ if (allowExpansion)
199
+ {
200
+ DirectoryUsageData[] allPaths = PersistentDirectorySettings.Instance.GetPaths(
201
+ toolName,
202
+ contextKey,
203
+ false,
204
+ 0
205
+ );
206
+ if (allPaths.Length > topN)
207
+ {
208
+ height +=
209
+ EditorGUIUtility.singleLineHeight
210
+ + EditorGUIUtility.standardVerticalSpacing;
211
+
212
+ string foldoutKey = $"{toolName}/{contextKey}_AllPathsHistory_EditorGUI";
213
+ bool isExpanded = ContextFoldoutStates.GetValueOrDefault(foldoutKey, false);
214
+ if (isExpanded)
215
+ {
216
+ height +=
217
+ Mathf.Max(1, allPaths.Skip(topN).Count())
218
+ * (
219
+ EditorGUIUtility.singleLineHeight
220
+ + EditorGUIUtility.standardVerticalSpacing
221
+ );
222
+ }
223
+ }
224
+ }
225
+ return height;
226
+ }
14
227
 
15
228
  public static float GetDrawFrequentPathsHeight(
16
229
  string toolName,
@@ -37,8 +250,9 @@
37
250
  return height;
38
251
  }
39
252
 
40
- height += EditorGUIUtility.singleLineHeight;
41
- height += topPaths.Length * EditorGUIUtility.singleLineHeight;
253
+ height +=
254
+ (1 + topPaths.Length)
255
+ * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
42
256
 
43
257
  if (allowExpansion)
44
258
  {
@@ -50,21 +264,19 @@
50
264
  );
51
265
  if (allPaths.Length > topN)
52
266
  {
53
- height += EditorGUIUtility.singleLineHeight;
267
+ height +=
268
+ EditorGUIUtility.singleLineHeight
269
+ + EditorGUIUtility.standardVerticalSpacing;
54
270
  string foldoutKey = $"{toolName}/{contextKey}_AllPathsHistory";
55
271
  bool isExpanded = ContextFoldoutStates.GetValueOrDefault(foldoutKey, false);
56
272
  if (isExpanded)
57
273
  {
58
- DirectoryUsageData[] pathsNotAlreadyInTop = allPaths.Skip(topN).ToArray();
59
- if (pathsNotAlreadyInTop.Any())
60
- {
61
- height +=
62
- pathsNotAlreadyInTop.Length * EditorGUIUtility.singleLineHeight;
63
- }
64
- else
65
- {
66
- height += EditorGUIUtility.singleLineHeight;
67
- }
274
+ height +=
275
+ Mathf.Max(1, allPaths.Skip(topN).Count())
276
+ * (
277
+ EditorGUIUtility.singleLineHeight
278
+ + EditorGUIUtility.standardVerticalSpacing
279
+ );
68
280
  }
69
281
  }
70
282
  }
@@ -111,11 +323,8 @@
111
323
  }
112
324
 
113
325
  float height = 0f;
114
-
115
326
  height += EditorGUIUtility.singleLineHeight;
116
-
117
327
  height += EditorGUIUtility.standardVerticalSpacing;
118
-
119
328
  string internalContextKey =
120
329
  $"{propertyForContext.serializedObject.targetObject.GetType().Name}_{propertyForContext.propertyPath}";
121
330
  height += GetPathSelectorHeight(toolName, internalContextKey);
@@ -356,7 +565,7 @@
356
565
  string currentPath,
357
566
  string toolName,
358
567
  string contextKey,
359
- System.Action<string> onPathChosen,
568
+ Action<string> onPathChosen,
360
569
  string dialogTitle = "Select Folder",
361
570
  float textFieldWidthOverride = -1f
362
571
  )
@@ -411,10 +620,7 @@
411
620
  }
412
621
  }
413
622
  }
414
- catch
415
- {
416
- // Swallow
417
- }
623
+ catch { }
418
624
  }
419
625
  if (!Directory.Exists(initialBrowsePath))
420
626
  {
@@ -476,7 +682,7 @@
476
682
  public static void DrawFrequentPaths(
477
683
  string toolName,
478
684
  string contextKey,
479
- System.Action<string> onPathClickedFromHistory,
685
+ Action<string> onPathClickedFromHistory,
480
686
  bool allowExpansion = true,
481
687
  int topN = 5,
482
688
  string listLabel = "Frequent Paths:"
@@ -6,13 +6,12 @@
6
6
  using UnityEngine;
7
7
  using UnityEditor;
8
8
  using System.Collections.Generic;
9
- using System.IO;
10
9
  using Core.Helper;
11
- using System.Linq;
12
10
 
13
11
  [CustomPropertyDrawer(typeof(SourceFolderEntry))]
14
12
  public sealed class SourceFolderEntryDrawer : PropertyDrawer
15
13
  {
14
+ private const string HistoryToolName = nameof(SourceFolderEntryDrawer);
16
15
  private static readonly Dictionary<string, bool> RegexesFoldoutState = new(
17
16
  StringComparer.Ordinal
18
17
  );
@@ -20,7 +19,6 @@
20
19
  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
21
20
  {
22
21
  EditorGUI.BeginProperty(position, label, property);
23
-
24
22
  Rect foldoutRect = new(
25
23
  position.x,
26
24
  position.y,
@@ -28,15 +26,14 @@
28
26
  EditorGUIUtility.singleLineHeight
29
27
  );
30
28
  property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label, true);
31
-
32
29
  if (property.isExpanded)
33
30
  {
34
31
  int originalIndent = EditorGUI.indentLevel;
35
32
  EditorGUI.indentLevel++;
36
-
37
33
  float currentY = foldoutRect.yMax + EditorGUIUtility.standardVerticalSpacing;
38
- float availableWidth = position.width - EditorGUI.indentLevel * 15f;
39
- float startX = position.x + EditorGUI.indentLevel * 15f;
34
+ float indentOffset = EditorGUI.indentLevel * 15f;
35
+ float startX = position.x + indentOffset;
36
+ float availableWidth = position.width - indentOffset;
40
37
 
41
38
  SerializedProperty folderPathProp = property.FindPropertyRelative(
42
39
  nameof(SourceFolderEntry.folderPath)
@@ -80,29 +77,16 @@
80
77
 
81
78
  if (GUI.Button(browseButtonRect, "Browse..."))
82
79
  {
83
- string initialBrowsePath = Application.dataPath;
84
- if (
85
- !string.IsNullOrWhiteSpace(folderPathProp.stringValue)
86
- && Directory.Exists(folderPathProp.stringValue)
87
- )
88
- {
89
- initialBrowsePath = folderPathProp.stringValue;
90
- }
91
-
80
+ string initialBrowsePath = Application.dataPath; /* ... */
92
81
  string selectedPathSys = EditorUtility.OpenFolderPanel(
93
82
  "Select Source Folder",
94
83
  initialBrowsePath,
95
84
  ""
96
85
  );
97
- if (!string.IsNullOrWhiteSpace(selectedPathSys))
86
+ if (!string.IsNullOrEmpty(selectedPathSys))
98
87
  {
99
88
  string processedPath = selectedPathSys.SanitizePath();
100
- if (
101
- processedPath.StartsWith(
102
- Application.dataPath.SanitizePath(),
103
- StringComparison.Ordinal
104
- )
105
- )
89
+ if (processedPath.StartsWith(Application.dataPath.SanitizePath()))
106
90
  {
107
91
  processedPath =
108
92
  "Assets"
@@ -111,12 +95,9 @@
111
95
  );
112
96
  }
113
97
  folderPathProp.stringValue = processedPath;
114
-
115
- string toolName = "SpriteAtlasTool_Drawer";
116
- string contextKey =
117
- $"{property.serializedObject.targetObject.GetType().Name}_{folderPathProp.propertyPath}";
98
+ string contextKey = GetFolderPathFoldoutKey(folderPathProp);
118
99
  PersistentDirectorySettings.Instance.RecordPath(
119
- toolName,
100
+ HistoryToolName,
120
101
  contextKey,
121
102
  processedPath
122
103
  );
@@ -125,66 +106,42 @@
125
106
  }
126
107
  }
127
108
  currentY += pathFieldRect.height + EditorGUIUtility.standardVerticalSpacing;
109
+ string historyContextKey = GetFolderPathFoldoutKey(folderPathProp);
128
110
 
129
- string historyContextKey =
130
- $"{property.serializedObject.targetObject.GetType().Name}_{folderPathProp.propertyPath}";
131
- DirectoryUsageData[] historyPaths = PersistentDirectorySettings.Instance.GetPaths(
132
- nameof(ScriptableSpriteAtlasEditor),
133
- historyContextKey,
134
- true,
135
- 3
111
+ Rect historyParentRect = new(
112
+ startX,
113
+ currentY,
114
+ availableWidth,
115
+ position.yMax - currentY
136
116
  );
137
- if (historyPaths.Any())
138
- {
139
- Rect historyLabelRect = new(
140
- startX,
141
- currentY,
142
- availableWidth,
143
- EditorGUIUtility.singleLineHeight
144
- );
145
- EditorGUI.LabelField(historyLabelRect, "History:", EditorStyles.miniBoldLabel);
146
- currentY += historyLabelRect.height;
147
117
 
148
- foreach (DirectoryUsageData dirData in historyPaths)
118
+ PersistentDirectoryGUI.DrawFrequentPathsWithEditorGUI(
119
+ historyParentRect,
120
+ ref currentY,
121
+ HistoryToolName,
122
+ historyContextKey,
123
+ chosenPath =>
149
124
  {
150
- Rect historyButtonRect = new(
151
- startX + 15f,
152
- currentY,
153
- availableWidth - 15f,
154
- EditorGUIUtility.singleLineHeight
125
+ folderPathProp.stringValue = chosenPath;
126
+ PersistentDirectorySettings.Instance.RecordPath(
127
+ HistoryToolName,
128
+ historyContextKey,
129
+ chosenPath
155
130
  );
156
- if (
157
- GUI.Button(
158
- historyButtonRect,
159
- new GUIContent($"({dirData.count}) {dirData.path}", dirData.path),
160
- EditorStyles.miniButtonLeft
161
- )
162
- )
163
- {
164
- folderPathProp.stringValue = dirData.path;
165
- PersistentDirectorySettings.Instance.RecordPath(
166
- nameof(ScriptableSpriteAtlasEditor),
167
- historyContextKey,
168
- dirData.path
169
- );
170
- property.serializedObject.ApplyModifiedProperties();
171
- GUI.FocusControl(null);
172
- }
173
- currentY += historyButtonRect.height;
131
+ property.serializedObject.ApplyModifiedProperties();
132
+ GUI.FocusControl(null);
174
133
  }
175
- currentY += EditorGUIUtility.standardVerticalSpacing;
176
- }
134
+ );
177
135
 
136
+ currentY += EditorGUIUtility.standardVerticalSpacing;
178
137
  Rect regexFoldoutLabelRect = new(
179
138
  startX,
180
139
  currentY,
181
140
  availableWidth,
182
141
  EditorGUIUtility.singleLineHeight
183
142
  );
184
- string regexesFoldoutKey =
185
- property.serializedObject.targetObject.name
186
- + property.propertyPath
187
- + ".regexesList";
143
+
144
+ string regexesFoldoutKey = GetRegexFoldoutKey(property);
188
145
  RegexesFoldoutState.TryAdd(regexesFoldoutKey, true);
189
146
  RegexesFoldoutState[regexesFoldoutKey] = EditorGUI.Foldout(
190
147
  regexFoldoutLabelRect,
@@ -193,25 +150,25 @@
193
150
  true
194
151
  );
195
152
  currentY += regexFoldoutLabelRect.height + EditorGUIUtility.standardVerticalSpacing;
153
+
196
154
  if (RegexesFoldoutState[regexesFoldoutKey])
197
155
  {
198
- int listElementIndent = EditorGUI.indentLevel;
156
+ int listElementIndentLvl = EditorGUI.indentLevel;
199
157
  EditorGUI.indentLevel++;
158
+ float regexStartX = startX + 15f;
159
+ float regexAvailableWidth = availableWidth - 15f;
200
160
  Rect sizeFieldRect = new(
201
- startX,
161
+ regexStartX,
202
162
  currentY,
203
- availableWidth,
163
+ regexAvailableWidth,
204
164
  EditorGUIUtility.singleLineHeight
205
165
  );
166
+
206
167
  EditorGUI.BeginChangeCheck();
207
168
  int newSize = EditorGUI.IntField(sizeFieldRect, "Size", regexesProp.arraySize);
208
169
  if (EditorGUI.EndChangeCheck())
209
170
  {
210
- if (newSize < 0)
211
- {
212
- newSize = 0;
213
- }
214
-
171
+ newSize = Mathf.Max(0, newSize);
215
172
  regexesProp.arraySize = newSize;
216
173
  }
217
174
  currentY += sizeFieldRect.height + EditorGUIUtility.standardVerticalSpacing;
@@ -220,9 +177,9 @@
220
177
  {
221
178
  SerializedProperty elementProp = regexesProp.GetArrayElementAtIndex(i);
222
179
  Rect elementRect = new(
223
- startX,
180
+ regexStartX,
224
181
  currentY,
225
- availableWidth,
182
+ regexAvailableWidth,
226
183
  EditorGUIUtility.singleLineHeight
227
184
  );
228
185
  EditorGUI.BeginChangeCheck();
@@ -237,9 +194,8 @@
237
194
  }
238
195
  currentY += elementRect.height + EditorGUIUtility.standardVerticalSpacing;
239
196
  }
240
- EditorGUI.indentLevel = listElementIndent;
197
+ EditorGUI.indentLevel = listElementIndentLvl;
241
198
  }
242
-
243
199
  EditorGUI.indentLevel = originalIndent;
244
200
  }
245
201
  EditorGUI.EndProperty();
@@ -256,48 +212,64 @@
256
212
  height += EditorGUIUtility.standardVerticalSpacing;
257
213
  height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
258
214
  height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
259
-
260
215
  SerializedProperty folderPathProp = property.FindPropertyRelative(
261
216
  nameof(SourceFolderEntry.folderPath)
262
217
  );
263
- string historyToolName = "SpriteAtlasTool_Drawer";
264
- string historyContextKey =
265
- $"{property.serializedObject.targetObject.GetType().Name}_{folderPathProp.propertyPath}";
266
- DirectoryUsageData[] historyPaths = PersistentDirectorySettings.Instance.GetPaths(
267
- historyToolName,
268
- historyContextKey,
269
- true,
270
- 3
218
+
219
+ string historyContextKey = GetFolderPathFoldoutKey(folderPathProp);
220
+
221
+ height += PersistentDirectoryGUI.GetDrawFrequentPathsHeightEditorGUI(
222
+ HistoryToolName,
223
+ historyContextKey
271
224
  );
272
- if (historyPaths.Any())
273
- {
274
- height += EditorGUIUtility.singleLineHeight;
275
- height += historyPaths.Length * EditorGUIUtility.singleLineHeight;
276
- height += EditorGUIUtility.standardVerticalSpacing;
277
- }
278
225
 
226
+ height += EditorGUIUtility.standardVerticalSpacing;
279
227
  height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
280
-
281
- string regexesFoldoutKey = property.propertyPath + ".regexesList";
228
+ string regexesFoldoutKey = GetRegexFoldoutKey(property);
282
229
  bool isRegexesExpanded = RegexesFoldoutState.GetValueOrDefault(regexesFoldoutKey, true);
283
-
284
230
  if (isRegexesExpanded)
285
231
  {
286
232
  SerializedProperty regexesProp = property.FindPropertyRelative(
287
233
  nameof(SourceFolderEntry.regexes)
288
234
  );
289
235
  height +=
290
- EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
291
- for (int i = 0; i < regexesProp.arraySize; i++)
292
- {
293
- height +=
294
- EditorGUIUtility.singleLineHeight
295
- + EditorGUIUtility.standardVerticalSpacing;
296
- }
236
+ (1 + regexesProp.arraySize)
237
+ * (
238
+ EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing
239
+ );
297
240
  }
298
241
  height += EditorGUIUtility.standardVerticalSpacing;
299
242
  return height;
300
243
  }
244
+
245
+ private static string GetHistoryContextKey(SerializedProperty property)
246
+ {
247
+ return (
248
+ property.serializedObject.targetObject != null
249
+ ? property.serializedObject.targetObject.name
250
+ : "NULL"
251
+ ) + ".DefaultHistoryContext";
252
+ }
253
+
254
+ private static string GetFolderPathFoldoutKey(SerializedProperty property)
255
+ {
256
+ return (
257
+ property.serializedObject.targetObject != null
258
+ ? property.serializedObject.targetObject.name
259
+ : "NULL"
260
+ ) + ".folderList";
261
+ }
262
+
263
+ private static string GetRegexFoldoutKey(SerializedProperty property)
264
+ {
265
+ return (
266
+ property.serializedObject.targetObject != null
267
+ ? property.serializedObject.targetObject.name
268
+ : "NULL"
269
+ )
270
+ + property.propertyPath
271
+ + ".regexesList";
272
+ }
301
273
  }
302
274
  #endif
303
275
  }
@@ -178,6 +178,37 @@
178
178
  SerializedObject serializedConfig = new(config);
179
179
  serializedConfig.Update();
180
180
  EditorGUI.BeginChangeCheck();
181
+
182
+ string currentAssetName = config.name;
183
+ Rect nameRect = EditorGUILayout.GetControlRect();
184
+ EditorGUI.BeginChangeCheck();
185
+ string newAssetName = EditorGUI.TextField(
186
+ new Rect(nameRect.x, nameRect.y, nameRect.width - 60, nameRect.height),
187
+ "Asset Name",
188
+ currentAssetName
189
+ );
190
+ if (EditorGUI.EndChangeCheck())
191
+ {
192
+ if (
193
+ !string.IsNullOrWhiteSpace(newAssetName)
194
+ && newAssetName != currentAssetName
195
+ && AssetDatabase.Contains(config)
196
+ )
197
+ {
198
+ string assetPath = AssetDatabase.GetAssetPath(config);
199
+ string error = AssetDatabase.RenameAsset(assetPath, newAssetName);
200
+ if (string.IsNullOrWhiteSpace(error))
201
+ {
202
+ LoadAtlasConfigs();
203
+ GUIUtility.ExitGUI();
204
+ }
205
+ else
206
+ {
207
+ this.LogError($"Failed to rename asset: {error}");
208
+ }
209
+ }
210
+ }
211
+
181
212
  SerializedProperty scriptProperty = serializedConfig.FindProperty("m_Script");
182
213
  if (scriptProperty != null)
183
214
  {
@@ -191,7 +222,7 @@
191
222
  while (property.NextVisible(enterChildren))
192
223
  {
193
224
  enterChildren = false;
194
- if (property.name == "m_Script")
225
+ if (string.Equals(property.name, "m_Script", StringComparison.Ordinal))
195
226
  {
196
227
  continue;
197
228
  }
@@ -736,18 +767,9 @@
736
767
 
737
768
  platformSettings.overridden = true;
738
769
  platformSettings.maxTextureSize = config.maxTextureSize;
739
-
740
- if (config.useCrunchCompression)
741
- {
742
- platformSettings.format = TextureImporterFormat.DXT5Crunched;
743
- platformSettings.crunchedCompression = true;
744
- platformSettings.compressionQuality = config.crunchCompressionLevel;
745
- }
746
- else
747
- {
748
- platformSettings.crunchedCompression = false;
749
- platformSettings.format = TextureImporterFormat.Automatic;
750
- }
770
+ platformSettings.crunchedCompression = config.useCrunchCompression;
771
+ platformSettings.compressionQuality = config.crunchCompressionLevel;
772
+ platformSettings.format = TextureImporterFormat.Automatic;
751
773
  platformSettings.textureCompression = config.compression;
752
774
  atlas.SetPlatformSettings(platformSettings);
753
775
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc73.16",
3
+ "version": "2.0.0-rc73.18",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -52,3 +52,5 @@
52
52
 
53
53
 
54
54
 
55
+
56
+