com.wallstop-studios.unity-helpers 2.0.0-rc73.17 → 2.0.0-rc73.19
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 +=
|
|
41
|
-
|
|
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 +=
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
39
|
-
float startX = position.x +
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
118
|
+
PersistentDirectoryGUI.DrawFrequentPathsWithEditorGUI(
|
|
119
|
+
historyParentRect,
|
|
120
|
+
ref currentY,
|
|
121
|
+
HistoryToolName,
|
|
122
|
+
historyContextKey,
|
|
123
|
+
chosenPath =>
|
|
149
124
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
125
|
+
folderPathProp.stringValue = chosenPath;
|
|
126
|
+
PersistentDirectorySettings.Instance.RecordPath(
|
|
127
|
+
HistoryToolName,
|
|
128
|
+
historyContextKey,
|
|
129
|
+
chosenPath
|
|
155
130
|
);
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
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
|
-
|
|
185
|
-
|
|
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
|
|
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
|
-
|
|
161
|
+
regexStartX,
|
|
202
162
|
currentY,
|
|
203
|
-
|
|
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
|
-
|
|
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
|
-
|
|
180
|
+
regexStartX,
|
|
224
181
|
currentY,
|
|
225
|
-
|
|
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 =
|
|
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
|
-
|
|
264
|
-
string historyContextKey =
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
}
|
|
@@ -111,32 +111,12 @@
|
|
|
111
111
|
|
|
112
112
|
if (GUILayout.Button("Generate/Update All .spriteatlas Assets", GUILayout.Height(40)))
|
|
113
113
|
{
|
|
114
|
-
|
|
115
|
-
EditorUtility.DisplayDialog(
|
|
116
|
-
"Generate All Atlases",
|
|
117
|
-
"This will create or update .spriteatlas assets based on all loaded configurations. Continue?",
|
|
118
|
-
"Yes",
|
|
119
|
-
"No"
|
|
120
|
-
)
|
|
121
|
-
)
|
|
122
|
-
{
|
|
123
|
-
GenerateAllAtlases();
|
|
124
|
-
}
|
|
114
|
+
GenerateAllAtlases();
|
|
125
115
|
}
|
|
126
116
|
|
|
127
117
|
if (GUILayout.Button("Pack All Generated Sprite Atlases", GUILayout.Height(40)))
|
|
128
118
|
{
|
|
129
|
-
|
|
130
|
-
EditorUtility.DisplayDialog(
|
|
131
|
-
"Pack All Atlases",
|
|
132
|
-
"This will pack all .spriteatlas assets in the project into textures. This can take some time. Continue?",
|
|
133
|
-
"Yes",
|
|
134
|
-
"No"
|
|
135
|
-
)
|
|
136
|
-
)
|
|
137
|
-
{
|
|
138
|
-
PackAllProjectAtlases();
|
|
139
|
-
}
|
|
119
|
+
PackAllProjectAtlases();
|
|
140
120
|
}
|
|
141
121
|
EditorGUILayout.Space(20);
|
|
142
122
|
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
|
|
@@ -583,7 +563,7 @@
|
|
|
583
563
|
foreach (Sprite sprite in result.spritesToAdd)
|
|
584
564
|
{
|
|
585
565
|
bool alreadyExists = false;
|
|
586
|
-
for (int i = 0; i < spritesListProp.arraySize; i
|
|
566
|
+
for (int i = 0; i < spritesListProp.arraySize; ++i)
|
|
587
567
|
{
|
|
588
568
|
if (spritesListProp.GetArrayElementAtIndex(i).objectReferenceValue == sprite)
|
|
589
569
|
{
|
|
@@ -633,7 +613,7 @@
|
|
|
633
613
|
int countRemoved = 0;
|
|
634
614
|
List<Sprite> spritesActuallyToRemove = new(result.spritesToRemove);
|
|
635
615
|
|
|
636
|
-
for (int i = spritesListProp.arraySize - 1;
|
|
616
|
+
for (int i = spritesListProp.arraySize - 1; 0 <= i; --i)
|
|
637
617
|
{
|
|
638
618
|
SerializedProperty element = spritesListProp.GetArrayElementAtIndex(i);
|
|
639
619
|
if (
|
|
@@ -700,11 +680,6 @@
|
|
|
700
680
|
EditorUtility.ClearProgressBar();
|
|
701
681
|
AssetDatabase.SaveAssets();
|
|
702
682
|
AssetDatabase.Refresh();
|
|
703
|
-
EditorUtility.DisplayDialog(
|
|
704
|
-
"Generation Complete",
|
|
705
|
-
$"Processed {totalConfigs} atlas configurations.",
|
|
706
|
-
"OK"
|
|
707
|
-
);
|
|
708
683
|
}
|
|
709
684
|
}
|
|
710
685
|
|
|
@@ -767,18 +742,9 @@
|
|
|
767
742
|
|
|
768
743
|
platformSettings.overridden = true;
|
|
769
744
|
platformSettings.maxTextureSize = config.maxTextureSize;
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
platformSettings.format = TextureImporterFormat.DXT5Crunched;
|
|
774
|
-
platformSettings.crunchedCompression = true;
|
|
775
|
-
platformSettings.compressionQuality = config.crunchCompressionLevel;
|
|
776
|
-
}
|
|
777
|
-
else
|
|
778
|
-
{
|
|
779
|
-
platformSettings.crunchedCompression = false;
|
|
780
|
-
platformSettings.format = TextureImporterFormat.Automatic;
|
|
781
|
-
}
|
|
745
|
+
platformSettings.crunchedCompression = config.useCrunchCompression;
|
|
746
|
+
platformSettings.compressionQuality = config.crunchCompressionLevel;
|
|
747
|
+
platformSettings.format = TextureImporterFormat.Automatic;
|
|
782
748
|
platformSettings.textureCompression = config.compression;
|
|
783
749
|
atlas.SetPlatformSettings(platformSettings);
|
|
784
750
|
|
|
@@ -853,7 +819,7 @@
|
|
|
853
819
|
AssetDatabase.StartAssetEditing();
|
|
854
820
|
try
|
|
855
821
|
{
|
|
856
|
-
for (int i = 0; i < spritesToProcess.Count; i
|
|
822
|
+
for (int i = 0; i < spritesToProcess.Count; ++i)
|
|
857
823
|
{
|
|
858
824
|
Sprite sprite = spritesToProcess[i];
|
|
859
825
|
EditorUtility.DisplayProgressBar(
|
|
@@ -957,11 +923,6 @@
|
|
|
957
923
|
$"Finished processing source sprite textures for '{config.name}'.\n"
|
|
958
924
|
+ $"Successfully modified importers for: {modifiedCount} textures.\n"
|
|
959
925
|
+ $"Errors/Skipped duplicates: {errorCount + (spritesToProcess.Count - processedAssetPaths.Count)}.";
|
|
960
|
-
EditorUtility.DisplayDialog(
|
|
961
|
-
"Source Sprite Modification Complete",
|
|
962
|
-
summaryMessage,
|
|
963
|
-
"OK"
|
|
964
|
-
);
|
|
965
926
|
this.Log($"{summaryMessage}");
|
|
966
927
|
}
|
|
967
928
|
}
|
package/package.json
CHANGED