com.wallstop-studios.unity-helpers 2.0.0-rc76.4 → 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.
- package/Editor/CustomDrawers/WShowIfPropertyDrawer.cs +1 -0
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs +4 -1
- package/Editor/CustomEditors/PolygonCollider2DOptimizerEditor.cs +40 -0
- package/Editor/CustomEditors/PolygonCollider2DOptimizerEditor.cs.meta +3 -0
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs +43 -31
- package/{Runtime/Core/Extension → Editor/Extensions}/SerializedPropertyExtensions.cs +1 -1
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs +9 -1
- package/Editor/Sprites/SpriteSheetAnimationCreator.cs +1218 -0
- package/Editor/Sprites/SpriteSheetAnimationCreator.cs.meta +3 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +29 -19
- package/Runtime/Core/Extension/DictionaryExtensions.cs +30 -10
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +12 -10
- package/Runtime/Core/Extension/IListExtensions.cs +6 -0
- package/Runtime/Core/Extension/UnityExtensions.cs +68 -0
- package/Runtime/Core/Helper/Helpers.cs +12 -0
- package/Runtime/Core/Helper/LineHelper.cs +194 -0
- package/Runtime/Core/Helper/LineHelper.cs.meta +3 -0
- package/Runtime/Tags/CollisionSenses.cs +91 -0
- package/Runtime/Tags/CollisionSenses.cs.meta +3 -0
- package/Runtime/Utils/ChildSpawner.cs +100 -0
- package/Runtime/Utils/ChildSpawner.cs.meta +3 -0
- package/Runtime/Utils/CollisionProxy.cs +48 -0
- package/Runtime/Utils/CollisionProxy.cs.meta +3 -0
- package/Runtime/Utils/PolygonCollider2DOptimizer.cs +83 -0
- package/Runtime/Utils/PolygonCollider2DOptimizer.cs.meta +3 -0
- package/Runtime/Utils/SerializedStringComparer.cs +107 -0
- package/Runtime/Utils/SerializedStringComparer.cs.meta +3 -0
- package/Runtime/Utils/UnityObjectNameComparer.cs +46 -1
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +2 -2
- package/package.json +3 -1
- /package/{Runtime/Core/Extension → Editor/Extensions}/SerializedPropertyExtensions.cs.meta +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Editor.CustomEditors
|
|
2
|
+
{
|
|
3
|
+
#if UNITY_EDITOR
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityHelpers.Utils;
|
|
7
|
+
|
|
8
|
+
[CustomEditor(typeof(PolygonCollider2DOptimizer))]
|
|
9
|
+
public sealed class PolygonCollider2DOptimizerEditor : Editor
|
|
10
|
+
{
|
|
11
|
+
private SerializedProperty _tolerance;
|
|
12
|
+
|
|
13
|
+
private void OnEnable()
|
|
14
|
+
{
|
|
15
|
+
_tolerance = serializedObject.FindProperty(
|
|
16
|
+
nameof(PolygonCollider2DOptimizer.tolerance)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public override void OnInspectorGUI()
|
|
21
|
+
{
|
|
22
|
+
serializedObject.Update();
|
|
23
|
+
if (EditorGUILayout.PropertyField(_tolerance))
|
|
24
|
+
{
|
|
25
|
+
serializedObject.ApplyModifiedProperties();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (GUILayout.Button("Optimize"))
|
|
29
|
+
{
|
|
30
|
+
PolygonCollider2DOptimizer optimizer = target as PolygonCollider2DOptimizer;
|
|
31
|
+
if (optimizer != null)
|
|
32
|
+
{
|
|
33
|
+
optimizer.Refresh();
|
|
34
|
+
}
|
|
35
|
+
serializedObject.ApplyModifiedProperties();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
}
|
|
@@ -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
|
-
|
|
157
|
-
|
|
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
|
-
|
|
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
|
|
179
|
-
Rect
|
|
161
|
+
SerializedProperty elemProp = regexesProp.GetArrayElementAtIndex(i);
|
|
162
|
+
Rect fieldRect = new(
|
|
180
163
|
regexStartX,
|
|
181
164
|
currentY,
|
|
182
|
-
|
|
165
|
+
regexWidth - 25f,
|
|
183
166
|
EditorGUIUtility.singleLineHeight
|
|
184
167
|
);
|
|
185
168
|
EditorGUI.BeginChangeCheck();
|
|
186
|
-
string
|
|
187
|
-
|
|
188
|
-
$"
|
|
189
|
-
|
|
169
|
+
string newVal = EditorGUI.TextField(
|
|
170
|
+
fieldRect,
|
|
171
|
+
$"Regex {i}:",
|
|
172
|
+
elemProp.stringValue
|
|
190
173
|
);
|
|
191
174
|
if (EditorGUI.EndChangeCheck())
|
|
192
175
|
{
|
|
193
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|