com.wallstop-studios.unity-helpers 2.0.0-rc22 → 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.
Files changed (58) hide show
  1. package/Editor/AnimationCopier.cs +39 -10
  2. package/Editor/AnimationCreator.cs +68 -24
  3. package/Editor/AnimationEventEditor.cs +206 -79
  4. package/Editor/AnimatorControllerCopier.cs +42 -14
  5. package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +5 -2
  6. package/Editor/PrefabCheckWizard.cs +37 -14
  7. package/Editor/SpriteSettingsApplier.cs +23 -9
  8. package/Editor/TextureResizerWizard.cs +37 -14
  9. package/Editor/TextureSettingsApplier.cs +23 -10
  10. package/Editor/Utils/EditorUtilities.cs +4 -2
  11. package/Editor/Utils/ReadOnlyPropertyDrawer.cs +2 -4
  12. package/Runtime/Core/Attributes/AnimationEventAttribute.cs +52 -23
  13. package/Runtime/Core/Attributes/KSerializableAttribute.cs +2 -6
  14. package/Runtime/Core/Attributes/NotNullAttribute.cs +3 -4
  15. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +1 -3
  16. package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +12 -6
  17. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +1 -0
  18. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +13 -8
  19. package/Runtime/Core/DataStructure/Adapters/KGuid.cs +24 -7
  20. package/Runtime/Core/DataStructure/Adapters/KVector2.cs +1 -0
  21. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  22. package/Runtime/Core/DataStructure/CyclicBuffer.cs +42 -44
  23. package/Runtime/Core/DataStructure/ISpatialTree.cs +22 -20
  24. package/Runtime/Core/Extension/CircleExtensions.cs +2 -2
  25. package/Runtime/Core/Extension/DictionaryExtensions.cs +62 -17
  26. package/Runtime/Core/Extension/StringExtensions.cs +30 -10
  27. package/Runtime/Core/Helper/Enumerables.cs +1 -1
  28. package/Runtime/Core/Helper/LifetimeHelpers.cs +2 -1
  29. package/Runtime/Core/Math/Line.cs +1 -1
  30. package/Runtime/Core/Math/Parabola.cs +4 -2
  31. package/Runtime/Core/Math/PointPolygonCheck.cs +12 -5
  32. package/Runtime/Core/Math/Range.cs +9 -8
  33. package/Runtime/Core/Math/XXHash.cs +22 -20
  34. package/Runtime/Core/Model/Direction.cs +26 -9
  35. package/Runtime/Core/OneOf/FastOneOf.cs +11 -4
  36. package/Runtime/Core/OneOf/None.cs +1 -3
  37. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +13 -4
  38. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +15 -5
  39. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +2 -3
  40. package/Runtime/Utils/AnimationEventEqualityComparer.cs +22 -10
  41. package/Runtime/Utils/AnimatorEnumStateMachine.cs +3 -4
  42. package/Runtime/Utils/Buffers.cs +1 -1
  43. package/Runtime/Utils/CenterPointOffset.cs +1 -2
  44. package/Runtime/Utils/CoroutineHandler.cs +1 -1
  45. package/Runtime/Utils/Oscillator.cs +4 -2
  46. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  47. package/Runtime/Utils/SpriteRendererSyncer.cs +5 -3
  48. package/Runtime/Utils/TextureScale.cs +21 -6
  49. package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +1 -1
  50. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +101 -0
  51. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs.meta +3 -0
  52. package/Tests/Runtime/DataStructures/QuadTreeTests.cs +1 -1
  53. package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +1 -1
  54. package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +41 -21
  55. package/Tests/Runtime/Extensions/StringExtensionTests.cs +1 -1
  56. package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +1 -1
  57. package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +1 -1
  58. 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", EditorUtilities.GetCurrentPathOfProjectWindow(), string.Empty);
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", EditorUtilities.GetCurrentPathOfProjectWindow(), string.Empty);
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 (string.IsNullOrEmpty(animationSourcePath) || string.IsNullOrEmpty(animationDestinationPath))
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 (string assetGuid in AssetDatabase.FindAssets("t:AnimationClip", new[] { animationSourcePath }))
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("Invalid AnimationClip (null) found at path '{0}', skipping.", path);
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(prefix, StringComparison.OrdinalIgnoreCase);
109
+ int prefixIndex = relativePath.LastIndexOf(
110
+ prefix,
111
+ StringComparison.OrdinalIgnoreCase
112
+ );
93
113
  if (prefixIndex < 0)
94
114
  {
95
- this.LogWarn("Unsupported animation at '{0}', expected to be prefixed by '{1}'.", path, prefix);
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 = animationDestinationPath + partialPath + relativePath.Substring(prefixIndex);
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("Failed to copy animation from '{0}' to '{1}'.", path, destination);
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 (data.frames is { Count: 0 } && GUILayout.Button("Fill Sprites From Animation Sources"))
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 (string assetGuid in AssetDatabase.FindAssets("t:sprite", animationPaths.ToArray()))
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 (data.frames is { Count: > 0 } && (filled || GUILayout.Button("Auto Parse Sprites")))
73
+ if (
74
+ data.frames is { Count: > 0 }
75
+ && (filled || GUILayout.Button("Auto Parse Sprites"))
76
+ )
66
77
  {
67
- Dictionary<string, Dictionary<string, List<Texture2D>>> texturesByPrefixAndAssetPath = new();
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, assetPathWithFrameName.LastIndexOf(frameName, StringComparison.Ordinal));
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 = lastUnderscoreIndex == lastNumericIndex - 1
86
- ? lastUnderscoreIndex
87
- : Math.Max(lastUnderscoreIndex, lastNumericIndex);
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 (KeyValuePair<string, Dictionary<string, List<Texture2D>>> assetPathAndTextures in
105
- texturesByPrefixAndAssetPath)
121
+ foreach (
122
+ KeyValuePair<
123
+ string,
124
+ Dictionary<string, List<Texture2D>>
125
+ > assetPathAndTextures in texturesByPrefixAndAssetPath
126
+ )
106
127
  {
107
- foreach (KeyValuePair<string, List<Texture2D>> textureAndPrefix in assetPathAndTextures
108
- .Value)
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 (animationData is { Count: > 0 } &&
124
- animationData.Any(data => data.frames is { Count: > 0 }) &&
125
- !string.IsNullOrWhiteSpace(text))
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(data.animationName.Length - text.Length);
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}.", framesPerSecond, animationName);
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("Ignoring animationData without frames with name {0}.", animationName);
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>(AssetDatabase.GetAssetPath(frame));
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("Ignoring animationData with empty frames with name {0}.", animationName);
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"), keyFrames.ToArray());
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, assetPathWithFileNameAndExtension.LastIndexOf("/", StringComparison.Ordinal) + 1);
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
+ }