com.wallstop-studios.unity-helpers 2.0.0-rc21 → 2.0.0-rc23
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/AnimationCopier.cs +39 -10
- package/Editor/AnimationCreator.cs +68 -24
- package/Editor/AnimationEventEditor.cs +206 -79
- package/Editor/AnimatorControllerCopier.cs +42 -14
- package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +5 -2
- package/Editor/PrefabCheckWizard.cs +37 -14
- package/Editor/SpriteSettingsApplier.cs +23 -9
- package/Editor/TextureResizerWizard.cs +37 -14
- package/Editor/TextureSettingsApplier.cs +23 -10
- package/Editor/Utils/EditorUtilities.cs +4 -2
- package/Editor/Utils/ReadOnlyPropertyDrawer.cs +2 -4
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs +52 -23
- package/Runtime/Core/Attributes/KSerializableAttribute.cs +2 -6
- package/Runtime/Core/Attributes/NotNullAttribute.cs +3 -4
- package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +1 -3
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +12 -6
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +1 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +13 -8
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs +24 -7
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs +1 -0
- package/Runtime/Core/DataStructure/Circle.cs +1 -1
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +42 -44
- package/Runtime/Core/DataStructure/ISpatialTree.cs +22 -20
- package/Runtime/Core/Extension/CircleExtensions.cs +2 -2
- package/Runtime/Core/Extension/DictionaryExtensions.cs +62 -17
- package/Runtime/Core/Extension/StringExtensions.cs +30 -10
- package/Runtime/Core/Helper/Enumerables.cs +1 -1
- package/Runtime/Core/Helper/LifetimeHelpers.cs +2 -1
- package/Runtime/Core/Math/Line.cs +1 -1
- package/Runtime/Core/Math/Parabola.cs +4 -2
- package/Runtime/Core/Math/PointPolygonCheck.cs +12 -5
- package/Runtime/Core/Math/Range.cs +9 -8
- package/Runtime/Core/Math/XXHash.cs +22 -20
- package/Runtime/Core/Model/Direction.cs +26 -9
- package/Runtime/Core/OneOf/FastOneOf.cs +11 -4
- package/Runtime/Core/OneOf/None.cs +1 -3
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +13 -4
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +15 -5
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +2 -3
- package/Runtime/Utils/AnimationEventEqualityComparer.cs +22 -10
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +3 -4
- package/Runtime/Utils/Buffers.cs +1 -1
- package/Runtime/Utils/CenterPointOffset.cs +1 -2
- package/Runtime/Utils/CoroutineHandler.cs +1 -1
- package/Runtime/Utils/Oscillator.cs +4 -2
- package/Runtime/Utils/SetTextureImportData.cs +1 -1
- package/Runtime/Utils/SpriteRendererMetadata.cs +56 -17
- package/Runtime/Utils/SpriteRendererSyncer.cs +5 -3
- package/Runtime/Utils/TextureScale.cs +21 -6
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +1 -1
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +101 -0
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs +1 -1
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +1 -1
- package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +41 -21
- package/Tests/Runtime/Extensions/StringExtensionTests.cs +1 -1
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +1 -1
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +1 -1
- package/package.json +3 -2
|
@@ -33,7 +33,10 @@
|
|
|
33
33
|
if (GUILayout.Button("Set Animation Source Path"))
|
|
34
34
|
{
|
|
35
35
|
string sourcePath = EditorUtility.OpenFolderPanel(
|
|
36
|
-
"Select Animation Source Path",
|
|
36
|
+
"Select Animation Source Path",
|
|
37
|
+
EditorUtilities.GetCurrentPathOfProjectWindow(),
|
|
38
|
+
string.Empty
|
|
39
|
+
);
|
|
37
40
|
int assetIndex = sourcePath?.IndexOf("Assets", StringComparison.Ordinal) ?? -1;
|
|
38
41
|
if (assetIndex < 0)
|
|
39
42
|
{
|
|
@@ -48,7 +51,10 @@
|
|
|
48
51
|
if (GUILayout.Button("Set Animation Destination Path"))
|
|
49
52
|
{
|
|
50
53
|
string sourcePath = EditorUtility.OpenFolderPanel(
|
|
51
|
-
"Select Animation Destination Path",
|
|
54
|
+
"Select Animation Destination Path",
|
|
55
|
+
EditorUtilities.GetCurrentPathOfProjectWindow(),
|
|
56
|
+
string.Empty
|
|
57
|
+
);
|
|
52
58
|
int assetIndex = sourcePath?.IndexOf("Assets", StringComparison.Ordinal) ?? -1;
|
|
53
59
|
if (assetIndex < 0)
|
|
54
60
|
{
|
|
@@ -70,29 +76,47 @@
|
|
|
70
76
|
return;
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
if (
|
|
79
|
+
if (
|
|
80
|
+
string.IsNullOrEmpty(animationSourcePath)
|
|
81
|
+
|| string.IsNullOrEmpty(animationDestinationPath)
|
|
82
|
+
)
|
|
74
83
|
{
|
|
75
84
|
return;
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
int processed = 0;
|
|
79
|
-
foreach (
|
|
88
|
+
foreach (
|
|
89
|
+
string assetGuid in AssetDatabase.FindAssets(
|
|
90
|
+
"t:AnimationClip",
|
|
91
|
+
new[] { animationSourcePath }
|
|
92
|
+
)
|
|
93
|
+
)
|
|
80
94
|
{
|
|
81
95
|
string path = AssetDatabase.GUIDToAssetPath(assetGuid);
|
|
82
96
|
|
|
83
97
|
AnimationClip animationClip = AssetDatabase.LoadAssetAtPath<AnimationClip>(path);
|
|
84
98
|
if (animationClip == null)
|
|
85
99
|
{
|
|
86
|
-
this.LogError(
|
|
100
|
+
this.LogError(
|
|
101
|
+
"Invalid AnimationClip (null) found at path '{0}', skipping.",
|
|
102
|
+
path
|
|
103
|
+
);
|
|
87
104
|
continue;
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
string prefix = animationClip.name;
|
|
91
108
|
string relativePath = path.Substring(animationSourcePath.Length);
|
|
92
|
-
int prefixIndex = relativePath.LastIndexOf(
|
|
109
|
+
int prefixIndex = relativePath.LastIndexOf(
|
|
110
|
+
prefix,
|
|
111
|
+
StringComparison.OrdinalIgnoreCase
|
|
112
|
+
);
|
|
93
113
|
if (prefixIndex < 0)
|
|
94
114
|
{
|
|
95
|
-
this.LogWarn(
|
|
115
|
+
this.LogWarn(
|
|
116
|
+
"Unsupported animation at '{0}', expected to be prefixed by '{1}'.",
|
|
117
|
+
path,
|
|
118
|
+
prefix
|
|
119
|
+
);
|
|
96
120
|
continue;
|
|
97
121
|
}
|
|
98
122
|
|
|
@@ -104,7 +128,8 @@
|
|
|
104
128
|
_ = Directory.CreateDirectory(outputPath);
|
|
105
129
|
}
|
|
106
130
|
|
|
107
|
-
string destination =
|
|
131
|
+
string destination =
|
|
132
|
+
animationDestinationPath + partialPath + relativePath.Substring(prefixIndex);
|
|
108
133
|
bool copySuccessful = AssetDatabase.CopyAsset(path, destination);
|
|
109
134
|
if (copySuccessful)
|
|
110
135
|
{
|
|
@@ -118,7 +143,11 @@
|
|
|
118
143
|
}
|
|
119
144
|
else
|
|
120
145
|
{
|
|
121
|
-
this.LogError(
|
|
146
|
+
this.LogError(
|
|
147
|
+
"Failed to copy animation from '{0}' to '{1}'.",
|
|
148
|
+
path,
|
|
149
|
+
destination
|
|
150
|
+
);
|
|
122
151
|
}
|
|
123
152
|
}
|
|
124
153
|
|
|
@@ -126,4 +155,4 @@
|
|
|
126
155
|
}
|
|
127
156
|
}
|
|
128
157
|
#endif
|
|
129
|
-
}
|
|
158
|
+
}
|
|
@@ -40,7 +40,10 @@
|
|
|
40
40
|
AnimationData data = animationData[0];
|
|
41
41
|
|
|
42
42
|
bool filled = false;
|
|
43
|
-
if (
|
|
43
|
+
if (
|
|
44
|
+
data.frames is { Count: 0 }
|
|
45
|
+
&& GUILayout.Button("Fill Sprites From Animation Sources")
|
|
46
|
+
)
|
|
44
47
|
{
|
|
45
48
|
List<string> animationPaths = new();
|
|
46
49
|
foreach (Object animationSource in animationSources)
|
|
@@ -49,7 +52,12 @@
|
|
|
49
52
|
animationPaths.Add(assetPath);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
foreach (
|
|
55
|
+
foreach (
|
|
56
|
+
string assetGuid in AssetDatabase.FindAssets(
|
|
57
|
+
"t:sprite",
|
|
58
|
+
animationPaths.ToArray()
|
|
59
|
+
)
|
|
60
|
+
)
|
|
53
61
|
{
|
|
54
62
|
string path = AssetDatabase.GUIDToAssetPath(assetGuid);
|
|
55
63
|
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
|
@@ -62,15 +70,23 @@
|
|
|
62
70
|
filled = true;
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
if (
|
|
73
|
+
if (
|
|
74
|
+
data.frames is { Count: > 0 }
|
|
75
|
+
&& (filled || GUILayout.Button("Auto Parse Sprites"))
|
|
76
|
+
)
|
|
66
77
|
{
|
|
67
|
-
Dictionary<
|
|
78
|
+
Dictionary<
|
|
79
|
+
string,
|
|
80
|
+
Dictionary<string, List<Texture2D>>
|
|
81
|
+
> texturesByPrefixAndAssetPath = new();
|
|
68
82
|
foreach (Texture2D frame in data.frames)
|
|
69
83
|
{
|
|
70
84
|
string assetPathWithFrameName = AssetDatabase.GetAssetPath(frame);
|
|
71
85
|
string frameName = frame.name;
|
|
72
86
|
string assetPath = assetPathWithFrameName.Substring(
|
|
73
|
-
0,
|
|
87
|
+
0,
|
|
88
|
+
assetPathWithFrameName.LastIndexOf(frameName, StringComparison.Ordinal)
|
|
89
|
+
);
|
|
74
90
|
int lastNumericIndex = frameName.Length - 1;
|
|
75
91
|
for (int i = frameName.Length - 1; 0 <= i; --i)
|
|
76
92
|
{
|
|
@@ -82,9 +98,10 @@
|
|
|
82
98
|
}
|
|
83
99
|
|
|
84
100
|
int lastUnderscoreIndex = frameName.LastIndexOf('_');
|
|
85
|
-
int lastIndex =
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
int lastIndex =
|
|
102
|
+
lastUnderscoreIndex == lastNumericIndex - 1
|
|
103
|
+
? lastUnderscoreIndex
|
|
104
|
+
: Math.Max(lastUnderscoreIndex, lastNumericIndex);
|
|
88
105
|
if (0 < lastIndex)
|
|
89
106
|
{
|
|
90
107
|
Dictionary<string, List<Texture2D>> texturesByPrefix =
|
|
@@ -101,17 +118,25 @@
|
|
|
101
118
|
if (0 < texturesByPrefixAndAssetPath.Count)
|
|
102
119
|
{
|
|
103
120
|
animationData.Clear();
|
|
104
|
-
foreach (
|
|
105
|
-
|
|
121
|
+
foreach (
|
|
122
|
+
KeyValuePair<
|
|
123
|
+
string,
|
|
124
|
+
Dictionary<string, List<Texture2D>>
|
|
125
|
+
> assetPathAndTextures in texturesByPrefixAndAssetPath
|
|
126
|
+
)
|
|
106
127
|
{
|
|
107
|
-
foreach (
|
|
108
|
-
|
|
128
|
+
foreach (
|
|
129
|
+
KeyValuePair<
|
|
130
|
+
string,
|
|
131
|
+
List<Texture2D>
|
|
132
|
+
> textureAndPrefix in assetPathAndTextures.Value
|
|
133
|
+
)
|
|
109
134
|
{
|
|
110
135
|
AnimationData newData = new()
|
|
111
136
|
{
|
|
112
137
|
frames = textureAndPrefix.Value,
|
|
113
138
|
framesPerSecond = data.framesPerSecond,
|
|
114
|
-
animationName = $"Anim_{textureAndPrefix.Key}"
|
|
139
|
+
animationName = $"Anim_{textureAndPrefix.Key}",
|
|
115
140
|
};
|
|
116
141
|
animationData.Add(newData);
|
|
117
142
|
}
|
|
@@ -120,9 +145,11 @@
|
|
|
120
145
|
}
|
|
121
146
|
}
|
|
122
147
|
|
|
123
|
-
if (
|
|
124
|
-
animationData
|
|
125
|
-
|
|
148
|
+
if (
|
|
149
|
+
animationData is { Count: > 0 }
|
|
150
|
+
&& animationData.Any(data => data.frames is { Count: > 0 })
|
|
151
|
+
&& !string.IsNullOrWhiteSpace(text)
|
|
152
|
+
)
|
|
126
153
|
{
|
|
127
154
|
if (GUILayout.Button("Append Text To All Animations"))
|
|
128
155
|
{
|
|
@@ -138,7 +165,9 @@
|
|
|
138
165
|
{
|
|
139
166
|
if (data.animationName.EndsWith(text))
|
|
140
167
|
{
|
|
141
|
-
data.animationName = data.animationName.Remove(
|
|
168
|
+
data.animationName = data.animationName.Remove(
|
|
169
|
+
data.animationName.Length - text.Length
|
|
170
|
+
);
|
|
142
171
|
}
|
|
143
172
|
}
|
|
144
173
|
}
|
|
@@ -167,14 +196,20 @@
|
|
|
167
196
|
if (framesPerSecond <= 0)
|
|
168
197
|
{
|
|
169
198
|
this.LogWarn(
|
|
170
|
-
"Ignoring animationData with FPS of {0} with name {1}.",
|
|
199
|
+
"Ignoring animationData with FPS of {0} with name {1}.",
|
|
200
|
+
framesPerSecond,
|
|
201
|
+
animationName
|
|
202
|
+
);
|
|
171
203
|
continue;
|
|
172
204
|
}
|
|
173
205
|
|
|
174
206
|
List<Texture2D> frames = data.frames;
|
|
175
207
|
if (frames is not { Count: > 0 })
|
|
176
208
|
{
|
|
177
|
-
this.LogWarn(
|
|
209
|
+
this.LogWarn(
|
|
210
|
+
"Ignoring animationData without frames with name {0}.",
|
|
211
|
+
animationName
|
|
212
|
+
);
|
|
178
213
|
continue;
|
|
179
214
|
}
|
|
180
215
|
|
|
@@ -184,7 +219,9 @@
|
|
|
184
219
|
float timeStep = 1f / framesPerSecond;
|
|
185
220
|
foreach (Texture2D frame in frames)
|
|
186
221
|
{
|
|
187
|
-
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(
|
|
222
|
+
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(
|
|
223
|
+
AssetDatabase.GetAssetPath(frame)
|
|
224
|
+
);
|
|
188
225
|
if (sprite == null)
|
|
189
226
|
{
|
|
190
227
|
continue;
|
|
@@ -198,21 +235,28 @@
|
|
|
198
235
|
|
|
199
236
|
if (keyFrames.Count <= 0)
|
|
200
237
|
{
|
|
201
|
-
this.LogWarn(
|
|
238
|
+
this.LogWarn(
|
|
239
|
+
"Ignoring animationData with empty frames with name {0}.",
|
|
240
|
+
animationName
|
|
241
|
+
);
|
|
202
242
|
continue;
|
|
203
243
|
}
|
|
204
244
|
|
|
205
245
|
AnimationClip animationClip = new();
|
|
206
246
|
AnimationUtility.SetObjectReferenceCurve(
|
|
207
247
|
animationClip,
|
|
208
|
-
EditorCurveBinding.PPtrCurve("", typeof(SpriteRenderer), "m_Sprite"),
|
|
248
|
+
EditorCurveBinding.PPtrCurve("", typeof(SpriteRenderer), "m_Sprite"),
|
|
249
|
+
keyFrames.ToArray()
|
|
250
|
+
);
|
|
209
251
|
string assetPathWithFileNameAndExtension = AssetDatabase.GetAssetPath(frames[0]);
|
|
210
252
|
string assetPath = assetPathWithFileNameAndExtension.Substring(
|
|
211
|
-
0,
|
|
253
|
+
0,
|
|
254
|
+
assetPathWithFileNameAndExtension.LastIndexOf("/", StringComparison.Ordinal) + 1
|
|
255
|
+
);
|
|
212
256
|
|
|
213
257
|
ProjectWindowUtil.CreateAsset(animationClip, assetPath + animationName + ".anim");
|
|
214
258
|
}
|
|
215
259
|
}
|
|
216
260
|
}
|
|
217
261
|
#endif
|
|
218
|
-
}
|
|
262
|
+
}
|