com.wallstop-studios.unity-helpers 2.0.0-rc73.19 → 2.0.0-rc73.2
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.
- package/Editor/{Sprites/AnimationCopier.cs → AnimationCopier.cs} +209 -84
- package/Editor/{Sprites/AnimationCreator.cs → AnimationCreator.cs} +100 -29
- package/Editor/AnimationEventEditor.cs +23 -10
- package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +1 -1
- package/Editor/FitTextureSizeWindow.cs +53 -14
- package/Editor/PrefabChecker.cs +18 -11
- package/Editor/SpriteAtlasGenerator.cs +914 -0
- package/Editor/SpriteAtlasGenerator.cs.meta +3 -0
- package/Editor/{Sprites/SpriteCropper.cs → SpriteCropper.cs} +143 -172
- package/Editor/{Sprites/SpriteSettingsApplier.cs → SpriteSettingsApplier.cs} +77 -12
- package/Editor/{Sprites/TextureResizerWizard.cs → TextureResizerWizard.cs} +1 -1
- package/Editor/{Sprites/TextureSettingsApplier.cs → TextureSettingsApplier.cs} +1 -1
- package/Editor/Utils/DxReadOnlyPropertyDrawer.cs +1 -1
- package/Editor/Utils/GUIHorizontalScope.cs +20 -0
- package/Editor/Utils/GUIHorizontalScope.cs.meta +3 -0
- package/Runtime/Core/DataStructure/Circle.cs +1 -1
- package/Runtime/Core/DataStructure/QuadTree.cs +4 -4
- package/Runtime/Core/Extension/ColorExtensions.cs +5 -5
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
- package/Runtime/Core/Extension/UnityExtensions.cs +14 -14
- package/Runtime/Core/Helper/DirectoryHelper.cs +0 -64
- package/Runtime/Core/Helper/Helpers.cs +9 -9
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +8 -31
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +4 -5
- package/Runtime/Core/Helper/PathHelper.cs +1 -2
- package/Runtime/Core/Random/DotNetRandom.cs +1 -1
- package/Runtime/Core/Random/SplitMix64.cs +1 -1
- package/Runtime/Core/Random/SquirrelRandom.cs +7 -7
- package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
- package/Runtime/Core/Random/WyRandom.cs +1 -1
- package/Runtime/Tags/AttributeEffect.cs +0 -1
- package/Runtime/Tags/EffectHandler.cs +1 -1
- package/Runtime/UI/LayeredImage.cs +161 -309
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
- package/Runtime/Utils/SetTextureImportData.cs +1 -1
- package/Runtime/Utils/TextureScale.cs +4 -4
- package/Styles/Elements/{Progress/CircularProgressBar.cs → CircularProgressBar.cs} +55 -56
- package/Styles/Elements/{Progress/RegularProgressBar.cs → RegularProgressBar.cs} +13 -24
- package/Styles/UXML/CircularProgressBar.uxml +11 -0
- package/Styles/UXML/CircularProgressBar.uxml.meta +10 -0
- package/Styles/UXML/RegularProgressBar.uxml +22 -0
- package/Styles/UXML/RegularProgressBar.uxml.meta +10 -0
- package/Styles/UXML.meta +3 -0
- package/package.json +1 -18
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs +0 -796
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs.meta +0 -3
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs +0 -275
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs.meta +0 -3
- package/Editor/PersistentDirectorySettings.cs +0 -248
- package/Editor/PersistentDirectorySettings.cs.meta +0 -3
- package/Editor/Sprites/ScriptableSpriteAtlas.cs +0 -95
- package/Editor/Sprites/ScriptableSpriteAtlas.cs.meta +0 -3
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs +0 -930
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs.meta +0 -3
- package/Editor/Sprites.meta +0 -3
- package/Styles/Elements/Progress/ArcedProgressBar.cs +0 -345
- package/Styles/Elements/Progress/ArcedProgressBar.cs.meta +0 -3
- package/Styles/Elements/Progress/GlitchProgressBar.cs +0 -416
- package/Styles/Elements/Progress/GlitchProgressBar.cs.meta +0 -3
- package/Styles/Elements/Progress/LiquidProgressBar.cs +0 -632
- package/Styles/Elements/Progress/LiquidProgressBar.cs.meta +0 -3
- package/Styles/Elements/Progress/MarchingAntsProgressBar.cs +0 -722
- package/Styles/Elements/Progress/MarchingAntsProgressBar.cs.meta +0 -3
- package/Styles/Elements/Progress/WigglyProgressBar.cs +0 -837
- package/Styles/Elements/Progress/WigglyProgressBar.cs.meta +0 -3
- package/Styles/Elements/Progress.meta +0 -3
- package/Styles/USS/ArcedProgressBar.uss +0 -19
- package/Styles/USS/ArcedProgressBar.uss.meta +0 -3
- package/Styles/USS/WigglyProgressBar.uss +0 -17
- package/Styles/USS/WigglyProgressBar.uss.meta +0 -3
- /package/Editor/{Sprites/AnimationCopier.cs.meta → AnimationCopier.cs.meta} +0 -0
- /package/Editor/{Sprites/AnimationCreator.cs.meta → AnimationCreator.cs.meta} +0 -0
- /package/Editor/{Sprites/SpriteCropper.cs.meta → SpriteCropper.cs.meta} +0 -0
- /package/Editor/{Sprites/SpriteSettingsApplier.cs.meta → SpriteSettingsApplier.cs.meta} +0 -0
- /package/Editor/{Sprites/TextureResizerWizard.cs.meta → TextureResizerWizard.cs.meta} +0 -0
- /package/Editor/{Sprites/TextureSettingsApplier.cs.meta → TextureSettingsApplier.cs.meta} +0 -0
- /package/Styles/Elements/{Progress/CircularProgressBar.cs.meta → CircularProgressBar.cs.meta} +0 -0
- /package/Styles/Elements/{Progress/RegularProgressBar.cs.meta → RegularProgressBar.cs.meta} +0 -0
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
namespace WallstopStudios.UnityHelpers.Editor.CustomEditors
|
|
2
|
-
{
|
|
3
|
-
#if UNITY_EDITOR
|
|
4
|
-
using System;
|
|
5
|
-
using Sprites;
|
|
6
|
-
using UnityEngine;
|
|
7
|
-
using UnityEditor;
|
|
8
|
-
using System.Collections.Generic;
|
|
9
|
-
using Core.Helper;
|
|
10
|
-
|
|
11
|
-
[CustomPropertyDrawer(typeof(SourceFolderEntry))]
|
|
12
|
-
public sealed class SourceFolderEntryDrawer : PropertyDrawer
|
|
13
|
-
{
|
|
14
|
-
private const string HistoryToolName = nameof(SourceFolderEntryDrawer);
|
|
15
|
-
private static readonly Dictionary<string, bool> RegexesFoldoutState = new(
|
|
16
|
-
StringComparer.Ordinal
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
20
|
-
{
|
|
21
|
-
EditorGUI.BeginProperty(position, label, property);
|
|
22
|
-
Rect foldoutRect = new(
|
|
23
|
-
position.x,
|
|
24
|
-
position.y,
|
|
25
|
-
position.width,
|
|
26
|
-
EditorGUIUtility.singleLineHeight
|
|
27
|
-
);
|
|
28
|
-
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label, true);
|
|
29
|
-
if (property.isExpanded)
|
|
30
|
-
{
|
|
31
|
-
int originalIndent = EditorGUI.indentLevel;
|
|
32
|
-
EditorGUI.indentLevel++;
|
|
33
|
-
float currentY = foldoutRect.yMax + EditorGUIUtility.standardVerticalSpacing;
|
|
34
|
-
float indentOffset = EditorGUI.indentLevel * 15f;
|
|
35
|
-
float startX = position.x + indentOffset;
|
|
36
|
-
float availableWidth = position.width - indentOffset;
|
|
37
|
-
|
|
38
|
-
SerializedProperty folderPathProp = property.FindPropertyRelative(
|
|
39
|
-
nameof(SourceFolderEntry.folderPath)
|
|
40
|
-
);
|
|
41
|
-
SerializedProperty regexesProp = property.FindPropertyRelative(
|
|
42
|
-
nameof(SourceFolderEntry.regexes)
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
Rect folderPathLabelRect = new(
|
|
46
|
-
startX,
|
|
47
|
-
currentY,
|
|
48
|
-
availableWidth,
|
|
49
|
-
EditorGUIUtility.singleLineHeight
|
|
50
|
-
);
|
|
51
|
-
EditorGUI.LabelField(folderPathLabelRect, "Folder Path", EditorStyles.boldLabel);
|
|
52
|
-
currentY += folderPathLabelRect.height + EditorGUIUtility.standardVerticalSpacing;
|
|
53
|
-
|
|
54
|
-
Rect pathFieldRect = new(
|
|
55
|
-
startX,
|
|
56
|
-
currentY,
|
|
57
|
-
availableWidth - 75,
|
|
58
|
-
EditorGUIUtility.singleLineHeight
|
|
59
|
-
);
|
|
60
|
-
Rect browseButtonRect = new(
|
|
61
|
-
pathFieldRect.xMax + 5,
|
|
62
|
-
currentY,
|
|
63
|
-
70,
|
|
64
|
-
EditorGUIUtility.singleLineHeight
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
EditorGUI.BeginChangeCheck();
|
|
68
|
-
string newPath = EditorGUI.TextField(
|
|
69
|
-
pathFieldRect,
|
|
70
|
-
new GUIContent("Path:"),
|
|
71
|
-
folderPathProp.stringValue
|
|
72
|
-
);
|
|
73
|
-
if (EditorGUI.EndChangeCheck())
|
|
74
|
-
{
|
|
75
|
-
folderPathProp.stringValue = newPath;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (GUI.Button(browseButtonRect, "Browse..."))
|
|
79
|
-
{
|
|
80
|
-
string initialBrowsePath = Application.dataPath; /* ... */
|
|
81
|
-
string selectedPathSys = EditorUtility.OpenFolderPanel(
|
|
82
|
-
"Select Source Folder",
|
|
83
|
-
initialBrowsePath,
|
|
84
|
-
""
|
|
85
|
-
);
|
|
86
|
-
if (!string.IsNullOrEmpty(selectedPathSys))
|
|
87
|
-
{
|
|
88
|
-
string processedPath = selectedPathSys.SanitizePath();
|
|
89
|
-
if (processedPath.StartsWith(Application.dataPath.SanitizePath()))
|
|
90
|
-
{
|
|
91
|
-
processedPath =
|
|
92
|
-
"Assets"
|
|
93
|
-
+ processedPath.Substring(
|
|
94
|
-
Application.dataPath.SanitizePath().Length
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
folderPathProp.stringValue = processedPath;
|
|
98
|
-
string contextKey = GetFolderPathFoldoutKey(folderPathProp);
|
|
99
|
-
PersistentDirectorySettings.Instance.RecordPath(
|
|
100
|
-
HistoryToolName,
|
|
101
|
-
contextKey,
|
|
102
|
-
processedPath
|
|
103
|
-
);
|
|
104
|
-
property.serializedObject.ApplyModifiedProperties();
|
|
105
|
-
GUI.FocusControl(null);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
currentY += pathFieldRect.height + EditorGUIUtility.standardVerticalSpacing;
|
|
109
|
-
string historyContextKey = GetFolderPathFoldoutKey(folderPathProp);
|
|
110
|
-
|
|
111
|
-
Rect historyParentRect = new(
|
|
112
|
-
startX,
|
|
113
|
-
currentY,
|
|
114
|
-
availableWidth,
|
|
115
|
-
position.yMax - currentY
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
PersistentDirectoryGUI.DrawFrequentPathsWithEditorGUI(
|
|
119
|
-
historyParentRect,
|
|
120
|
-
ref currentY,
|
|
121
|
-
HistoryToolName,
|
|
122
|
-
historyContextKey,
|
|
123
|
-
chosenPath =>
|
|
124
|
-
{
|
|
125
|
-
folderPathProp.stringValue = chosenPath;
|
|
126
|
-
PersistentDirectorySettings.Instance.RecordPath(
|
|
127
|
-
HistoryToolName,
|
|
128
|
-
historyContextKey,
|
|
129
|
-
chosenPath
|
|
130
|
-
);
|
|
131
|
-
property.serializedObject.ApplyModifiedProperties();
|
|
132
|
-
GUI.FocusControl(null);
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
currentY += EditorGUIUtility.standardVerticalSpacing;
|
|
137
|
-
Rect regexFoldoutLabelRect = new(
|
|
138
|
-
startX,
|
|
139
|
-
currentY,
|
|
140
|
-
availableWidth,
|
|
141
|
-
EditorGUIUtility.singleLineHeight
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
string regexesFoldoutKey = GetRegexFoldoutKey(property);
|
|
145
|
-
RegexesFoldoutState.TryAdd(regexesFoldoutKey, true);
|
|
146
|
-
RegexesFoldoutState[regexesFoldoutKey] = EditorGUI.Foldout(
|
|
147
|
-
regexFoldoutLabelRect,
|
|
148
|
-
RegexesFoldoutState[regexesFoldoutKey],
|
|
149
|
-
"Regexes (AND logic)",
|
|
150
|
-
true
|
|
151
|
-
);
|
|
152
|
-
currentY += regexFoldoutLabelRect.height + EditorGUIUtility.standardVerticalSpacing;
|
|
153
|
-
|
|
154
|
-
if (RegexesFoldoutState[regexesFoldoutKey])
|
|
155
|
-
{
|
|
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
|
|
165
|
-
);
|
|
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;
|
|
175
|
-
|
|
176
|
-
for (int i = 0; i < regexesProp.arraySize; i++)
|
|
177
|
-
{
|
|
178
|
-
SerializedProperty elementProp = regexesProp.GetArrayElementAtIndex(i);
|
|
179
|
-
Rect elementRect = new(
|
|
180
|
-
regexStartX,
|
|
181
|
-
currentY,
|
|
182
|
-
regexAvailableWidth,
|
|
183
|
-
EditorGUIUtility.singleLineHeight
|
|
184
|
-
);
|
|
185
|
-
EditorGUI.BeginChangeCheck();
|
|
186
|
-
string newStringValue = EditorGUI.TextField(
|
|
187
|
-
elementRect,
|
|
188
|
-
$"Element {i}",
|
|
189
|
-
elementProp.stringValue
|
|
190
|
-
);
|
|
191
|
-
if (EditorGUI.EndChangeCheck())
|
|
192
|
-
{
|
|
193
|
-
elementProp.stringValue = newStringValue;
|
|
194
|
-
}
|
|
195
|
-
currentY += elementRect.height + EditorGUIUtility.standardVerticalSpacing;
|
|
196
|
-
}
|
|
197
|
-
EditorGUI.indentLevel = listElementIndentLvl;
|
|
198
|
-
}
|
|
199
|
-
EditorGUI.indentLevel = originalIndent;
|
|
200
|
-
}
|
|
201
|
-
EditorGUI.EndProperty();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
|
205
|
-
{
|
|
206
|
-
float height = EditorGUIUtility.singleLineHeight;
|
|
207
|
-
if (!property.isExpanded)
|
|
208
|
-
{
|
|
209
|
-
return height;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
height += EditorGUIUtility.standardVerticalSpacing;
|
|
213
|
-
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
214
|
-
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
215
|
-
SerializedProperty folderPathProp = property.FindPropertyRelative(
|
|
216
|
-
nameof(SourceFolderEntry.folderPath)
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
string historyContextKey = GetFolderPathFoldoutKey(folderPathProp);
|
|
220
|
-
|
|
221
|
-
height += PersistentDirectoryGUI.GetDrawFrequentPathsHeightEditorGUI(
|
|
222
|
-
HistoryToolName,
|
|
223
|
-
historyContextKey
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
height += EditorGUIUtility.standardVerticalSpacing;
|
|
227
|
-
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
228
|
-
string regexesFoldoutKey = GetRegexFoldoutKey(property);
|
|
229
|
-
bool isRegexesExpanded = RegexesFoldoutState.GetValueOrDefault(regexesFoldoutKey, true);
|
|
230
|
-
if (isRegexesExpanded)
|
|
231
|
-
{
|
|
232
|
-
SerializedProperty regexesProp = property.FindPropertyRelative(
|
|
233
|
-
nameof(SourceFolderEntry.regexes)
|
|
234
|
-
);
|
|
235
|
-
height +=
|
|
236
|
-
(1 + regexesProp.arraySize)
|
|
237
|
-
* (
|
|
238
|
-
EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
height += EditorGUIUtility.standardVerticalSpacing;
|
|
242
|
-
return height;
|
|
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
|
-
}
|
|
273
|
-
}
|
|
274
|
-
#endif
|
|
275
|
-
}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
namespace WallstopStudios.UnityHelpers.Editor
|
|
2
|
-
{
|
|
3
|
-
#if UNITY_EDITOR
|
|
4
|
-
using System;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
using UnityEditor;
|
|
7
|
-
using System.Collections.Generic;
|
|
8
|
-
using System.Linq;
|
|
9
|
-
using System.IO;
|
|
10
|
-
using Core.Helper;
|
|
11
|
-
using UnityEngine.Serialization;
|
|
12
|
-
|
|
13
|
-
[Serializable]
|
|
14
|
-
public sealed class DirectoryUsageData
|
|
15
|
-
{
|
|
16
|
-
public string path;
|
|
17
|
-
public int count;
|
|
18
|
-
public long lastUsedTicks;
|
|
19
|
-
|
|
20
|
-
public DirectoryUsageData(string p)
|
|
21
|
-
{
|
|
22
|
-
path = p;
|
|
23
|
-
count = 0;
|
|
24
|
-
lastUsedTicks = DateTime.UtcNow.Ticks;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public void MarkUsed()
|
|
28
|
-
{
|
|
29
|
-
count++;
|
|
30
|
-
lastUsedTicks = DateTime.UtcNow.Ticks;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[Serializable]
|
|
35
|
-
public sealed class ContextHistory
|
|
36
|
-
{
|
|
37
|
-
public string contextKey;
|
|
38
|
-
public List<DirectoryUsageData> directories = new();
|
|
39
|
-
|
|
40
|
-
public ContextHistory() { }
|
|
41
|
-
|
|
42
|
-
public ContextHistory(string key)
|
|
43
|
-
{
|
|
44
|
-
contextKey = key;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public DirectoryUsageData GetOrAddDirectory(string path)
|
|
48
|
-
{
|
|
49
|
-
DirectoryUsageData dirData = directories.Find(directoryData =>
|
|
50
|
-
string.Equals(directoryData.path, path, StringComparison.Ordinal)
|
|
51
|
-
);
|
|
52
|
-
if (dirData != null)
|
|
53
|
-
{
|
|
54
|
-
return dirData;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
dirData = new DirectoryUsageData(path);
|
|
58
|
-
directories.Add(dirData);
|
|
59
|
-
return dirData;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
[Serializable]
|
|
64
|
-
public sealed class ToolHistory
|
|
65
|
-
{
|
|
66
|
-
public string toolName;
|
|
67
|
-
public List<ContextHistory> contexts = new();
|
|
68
|
-
|
|
69
|
-
public ToolHistory() { }
|
|
70
|
-
|
|
71
|
-
public ToolHistory(string name)
|
|
72
|
-
{
|
|
73
|
-
toolName = name;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public ContextHistory GetOrAddContext(string contextKey)
|
|
77
|
-
{
|
|
78
|
-
ContextHistory context = contexts.Find(c =>
|
|
79
|
-
string.Equals(c.contextKey, contextKey, StringComparison.Ordinal)
|
|
80
|
-
);
|
|
81
|
-
if (context != null)
|
|
82
|
-
{
|
|
83
|
-
return context;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
context = new ContextHistory(contextKey);
|
|
87
|
-
contexts.Add(context);
|
|
88
|
-
return context;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public sealed class PersistentDirectorySettings : ScriptableObject
|
|
93
|
-
{
|
|
94
|
-
private const string DefaultAssetPath = "Assets/Editor/PersistentDirectorySettings.asset";
|
|
95
|
-
|
|
96
|
-
[FormerlySerializedAs("allToolHistories")]
|
|
97
|
-
[SerializeField]
|
|
98
|
-
private List<ToolHistory> _allToolHistories = new();
|
|
99
|
-
|
|
100
|
-
private static PersistentDirectorySettings _instance;
|
|
101
|
-
|
|
102
|
-
public static PersistentDirectorySettings Instance
|
|
103
|
-
{
|
|
104
|
-
get
|
|
105
|
-
{
|
|
106
|
-
if (_instance == null)
|
|
107
|
-
{
|
|
108
|
-
PersistentDirectorySettings[] settings = AssetDatabase
|
|
109
|
-
.FindAssets($"t:{nameof(PersistentDirectorySettings)}")
|
|
110
|
-
.Select(AssetDatabase.GUIDToAssetPath)
|
|
111
|
-
.Select(AssetDatabase.LoadAssetAtPath<PersistentDirectorySettings>)
|
|
112
|
-
.Where(Objects.NotNull)
|
|
113
|
-
.ToArray();
|
|
114
|
-
|
|
115
|
-
if (settings.Length > 0)
|
|
116
|
-
{
|
|
117
|
-
if (settings.Length > 1)
|
|
118
|
-
{
|
|
119
|
-
Debug.LogWarning(
|
|
120
|
-
$"Multiple instances of {nameof(PersistentDirectorySettings)} found. Using the first one at: {AssetDatabase.GetAssetPath(settings[0])}. Please ensure only one instance exists for consistent behavior."
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
_instance = settings[0];
|
|
125
|
-
}
|
|
126
|
-
else
|
|
127
|
-
{
|
|
128
|
-
if (_instance == null)
|
|
129
|
-
{
|
|
130
|
-
Debug.Log(
|
|
131
|
-
$"No instance of {nameof(PersistentDirectorySettings)} found. Creating a new one at {DefaultAssetPath}."
|
|
132
|
-
);
|
|
133
|
-
_instance = CreateInstance<PersistentDirectorySettings>();
|
|
134
|
-
|
|
135
|
-
string directoryPath = Path.GetDirectoryName(DefaultAssetPath);
|
|
136
|
-
if (
|
|
137
|
-
!string.IsNullOrWhiteSpace(directoryPath)
|
|
138
|
-
&& !Directory.Exists(directoryPath)
|
|
139
|
-
)
|
|
140
|
-
{
|
|
141
|
-
Directory.CreateDirectory(directoryPath);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
AssetDatabase.CreateAsset(_instance, DefaultAssetPath);
|
|
145
|
-
AssetDatabase.SaveAssets();
|
|
146
|
-
AssetDatabase.Refresh();
|
|
147
|
-
EditorUtility.FocusProjectWindow();
|
|
148
|
-
Selection.activeObject = _instance;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (_instance == null)
|
|
154
|
-
{
|
|
155
|
-
Debug.LogError(
|
|
156
|
-
$"Failed to find or create {nameof(PersistentDirectorySettings)}. Directory persistence will not work."
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return _instance;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private ToolHistory GetOrAddToolHistory(string toolName)
|
|
165
|
-
{
|
|
166
|
-
ToolHistory toolHistory = _allToolHistories.Find(toolHistory =>
|
|
167
|
-
string.Equals(toolHistory.toolName, toolName, StringComparison.Ordinal)
|
|
168
|
-
);
|
|
169
|
-
if (toolHistory != null)
|
|
170
|
-
{
|
|
171
|
-
return toolHistory;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
toolHistory = new ToolHistory(toolName);
|
|
175
|
-
_allToolHistories.Add(toolHistory);
|
|
176
|
-
|
|
177
|
-
return toolHistory;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public void RecordPath(string toolName, string contextKey, string path)
|
|
181
|
-
{
|
|
182
|
-
if (
|
|
183
|
-
string.IsNullOrWhiteSpace(toolName)
|
|
184
|
-
|| string.IsNullOrWhiteSpace(contextKey)
|
|
185
|
-
|| string.IsNullOrWhiteSpace(path)
|
|
186
|
-
)
|
|
187
|
-
{
|
|
188
|
-
Debug.LogWarning("RecordPath: toolName, contextKey, or path cannot be empty.");
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
string sanitizedPath = path.SanitizePath();
|
|
193
|
-
if (
|
|
194
|
-
!sanitizedPath.StartsWith("Assets/", StringComparison.Ordinal)
|
|
195
|
-
|| !AssetDatabase.IsValidFolder(sanitizedPath)
|
|
196
|
-
)
|
|
197
|
-
{
|
|
198
|
-
if (
|
|
199
|
-
!Path.IsPathRooted(sanitizedPath)
|
|
200
|
-
&& !sanitizedPath.StartsWith("Assets/", StringComparison.Ordinal)
|
|
201
|
-
)
|
|
202
|
-
{
|
|
203
|
-
Debug.LogWarning(
|
|
204
|
-
$"Recording path '{sanitizedPath}' that is not an 'Assets/' relative path or an absolute path. This might be intentional."
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
ToolHistory tool = GetOrAddToolHistory(toolName);
|
|
210
|
-
ContextHistory context = tool.GetOrAddContext(contextKey);
|
|
211
|
-
DirectoryUsageData dirData = context.GetOrAddDirectory(sanitizedPath);
|
|
212
|
-
dirData.MarkUsed();
|
|
213
|
-
EditorUtility.SetDirty(this);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
public DirectoryUsageData[] GetPaths(
|
|
217
|
-
string toolName,
|
|
218
|
-
string contextKey,
|
|
219
|
-
bool topOnly = false,
|
|
220
|
-
int topN = 5
|
|
221
|
-
)
|
|
222
|
-
{
|
|
223
|
-
ToolHistory tool = _allToolHistories.Find(th =>
|
|
224
|
-
string.Equals(th.toolName, toolName, StringComparison.Ordinal)
|
|
225
|
-
);
|
|
226
|
-
if (tool == null)
|
|
227
|
-
{
|
|
228
|
-
return Array.Empty<DirectoryUsageData>();
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
ContextHistory context = tool.contexts.Find(c =>
|
|
232
|
-
string.Equals(c.contextKey, contextKey, StringComparison.Ordinal)
|
|
233
|
-
);
|
|
234
|
-
if (context == null)
|
|
235
|
-
{
|
|
236
|
-
return Array.Empty<DirectoryUsageData>();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
DirectoryUsageData[] sortedDirectories = context
|
|
240
|
-
.directories.OrderByDescending(directoryData => directoryData.count)
|
|
241
|
-
.ThenByDescending(directoryData => directoryData.lastUsedTicks)
|
|
242
|
-
.ToArray();
|
|
243
|
-
|
|
244
|
-
return topOnly ? sortedDirectories.Take(topN).ToArray() : sortedDirectories;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
#endif
|
|
248
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
2
|
-
{
|
|
3
|
-
#if UNITY_EDITOR
|
|
4
|
-
using UnityEngine;
|
|
5
|
-
using System.Collections.Generic;
|
|
6
|
-
using Core.Attributes;
|
|
7
|
-
using Core.Helper;
|
|
8
|
-
using UnityEditor;
|
|
9
|
-
|
|
10
|
-
[System.Serializable]
|
|
11
|
-
public sealed class SourceFolderEntry
|
|
12
|
-
{
|
|
13
|
-
[Tooltip("Folder to scan for sprites. Path relative to Assets/.")]
|
|
14
|
-
public string folderPath = "Assets/Sprites/";
|
|
15
|
-
|
|
16
|
-
[Tooltip(
|
|
17
|
-
"Regex patterns to match sprite file names within this specific folder. All regexes must match (AND logic). e.g., \"^icon_.*\\.png$\""
|
|
18
|
-
)]
|
|
19
|
-
public List<string> regexes = new();
|
|
20
|
-
|
|
21
|
-
public SourceFolderEntry() { }
|
|
22
|
-
|
|
23
|
-
public SourceFolderEntry(string path)
|
|
24
|
-
{
|
|
25
|
-
folderPath = path;
|
|
26
|
-
regexes = new List<string>();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
[CreateAssetMenu(
|
|
31
|
-
fileName = "NewScriptableSpriteAtlas",
|
|
32
|
-
menuName = "Wallstop Studios/Unity Helpers/Scriptable Sprite Atlas Config"
|
|
33
|
-
)]
|
|
34
|
-
public sealed class ScriptableSpriteAtlas : ScriptableObject
|
|
35
|
-
{
|
|
36
|
-
[Header("Sprite Sources")]
|
|
37
|
-
[Tooltip(
|
|
38
|
-
"Manually added sprites. These will always be included in addition to scanned sprites."
|
|
39
|
-
)]
|
|
40
|
-
public List<Sprite> spritesToPack = new();
|
|
41
|
-
|
|
42
|
-
[Tooltip("Define folders and their specific regex patterns for finding sprites.")]
|
|
43
|
-
public List<SourceFolderEntry> sourceFolderEntries = new();
|
|
44
|
-
|
|
45
|
-
[Header("Output Atlas Settings")]
|
|
46
|
-
[Tooltip("Directory where the .spriteatlas asset will be saved. Relative to Assets/.")]
|
|
47
|
-
public string outputSpriteAtlasDirectory = "Assets/Sprites/SpriteAtlas";
|
|
48
|
-
public string outputSpriteAtlasName = "MyNewAtlas";
|
|
49
|
-
|
|
50
|
-
public string FullOutputPath
|
|
51
|
-
{
|
|
52
|
-
get
|
|
53
|
-
{
|
|
54
|
-
if (
|
|
55
|
-
string.IsNullOrWhiteSpace(outputSpriteAtlasDirectory)
|
|
56
|
-
|| string.IsNullOrWhiteSpace(outputSpriteAtlasName)
|
|
57
|
-
)
|
|
58
|
-
{
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return System
|
|
63
|
-
.IO.Path.Combine(
|
|
64
|
-
outputSpriteAtlasDirectory,
|
|
65
|
-
outputSpriteAtlasName + ".spriteatlas"
|
|
66
|
-
)
|
|
67
|
-
.SanitizePath();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
[Header("Packing Settings")]
|
|
72
|
-
public int maxTextureSize = 16384;
|
|
73
|
-
|
|
74
|
-
[Tooltip("Allow Unity to rotate sprites to fit them better.")]
|
|
75
|
-
public bool enableRotation = true;
|
|
76
|
-
|
|
77
|
-
[Tooltip("Padding in pixels between sprites in the atlas.")]
|
|
78
|
-
public int padding = 4;
|
|
79
|
-
|
|
80
|
-
[Tooltip(
|
|
81
|
-
"Enable Read/Write on the generated atlas texture. Needed for some runtime operations, but increases memory."
|
|
82
|
-
)]
|
|
83
|
-
public bool readWriteEnabled = true;
|
|
84
|
-
|
|
85
|
-
[Header("Compression Settings")]
|
|
86
|
-
public bool useCrunchCompression = true;
|
|
87
|
-
|
|
88
|
-
[Range(0, 100)]
|
|
89
|
-
[WShowIf(nameof(useCrunchCompression))]
|
|
90
|
-
public int crunchCompressionLevel = 50;
|
|
91
|
-
|
|
92
|
-
public TextureImporterCompression compression = TextureImporterCompression.Compressed;
|
|
93
|
-
}
|
|
94
|
-
#endif
|
|
95
|
-
}
|