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
@@ -18,14 +18,15 @@
18
18
 
19
19
  static AnimationEventEditor()
20
20
  {
21
- Dictionary<Type, IReadOnlyList<MethodInfo>> typesToMethods = AppDomain.CurrentDomain
22
- .GetAssemblies()
21
+ Dictionary<Type, IReadOnlyList<MethodInfo>> typesToMethods = AppDomain
22
+ .CurrentDomain.GetAssemblies()
23
23
  .SelectMany(assembly => assembly.GetTypes())
24
24
  .Where(type => type.IsClass)
25
25
  .Where(type => typeof(MonoBehaviour).IsAssignableFrom(type))
26
26
  .ToDictionary(
27
27
  type => type,
28
- type => (IReadOnlyList<MethodInfo>)type.GetPossibleAnimatorEventsForType());
28
+ type => (IReadOnlyList<MethodInfo>)type.GetPossibleAnimatorEventsForType()
29
+ );
29
30
  foreach (KeyValuePair<Type, IReadOnlyList<MethodInfo>> entry in typesToMethods.ToList())
30
31
  {
31
32
  if (entry.Value.Count <= 0)
@@ -37,7 +38,6 @@
37
38
  TypesToMethods = typesToMethods;
38
39
  }
39
40
 
40
-
41
41
  [MenuItem("Tools/Unity Helpers/AnimationEvent Editor")]
42
42
  private static void AnimationEventEditorMenu()
43
43
  {
@@ -68,7 +68,9 @@
68
68
  _explicitMode ? AnimationEventHelpers.TypesToMethods : TypesToMethods;
69
69
 
70
70
  private int MaxFrameIndex =>
71
- _currentClip == null ? 0 : (int)Math.Round(_currentClip.frameRate * _currentClip.length);
71
+ _currentClip == null
72
+ ? 0
73
+ : (int)Math.Round(_currentClip.frameRate * _currentClip.length);
72
74
 
73
75
  private Vector2 _scrollPosition;
74
76
  private Animator _sourceAnimator;
@@ -82,15 +84,22 @@
82
84
  private readonly List<AnimationEventItem> _state = new();
83
85
  private readonly Dictionary<AnimationEventItem, string> _lastSeenSearch = new();
84
86
 
85
- private readonly Dictionary<AnimationEventItem, IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>>> _lookups =
86
- new();
87
+ private readonly Dictionary<
88
+ AnimationEventItem,
89
+ IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>>
90
+ > _lookups = new();
87
91
 
88
92
  private int _selectedFrameIndex = -1;
89
93
 
90
94
  private void OnGUI()
91
95
  {
92
- Animator tmpAnimator = EditorGUILayout.ObjectField(
93
- "Animator Object", _sourceAnimator, typeof(Animator), true) as Animator;
96
+ Animator tmpAnimator =
97
+ EditorGUILayout.ObjectField(
98
+ "Animator Object",
99
+ _sourceAnimator,
100
+ typeof(Animator),
101
+ true
102
+ ) as Animator;
94
103
  if (tmpAnimator == null)
95
104
  {
96
105
  _sourceAnimator = null;
@@ -106,13 +115,18 @@
106
115
 
107
116
  _explicitMode = EditorGUILayout.Toggle(
108
117
  new GUIContent(
109
- "Explicit Mode", "If true, restricts results to only those that explicitly with [AnimationEvent]"),
110
- _explicitMode);
118
+ "Explicit Mode",
119
+ "If true, restricts results to only those that explicitly with [AnimationEvent]"
120
+ ),
121
+ _explicitMode
122
+ );
111
123
  _controlFrameTime = EditorGUILayout.Toggle(
112
124
  new GUIContent(
113
125
  "Control Frame Time",
114
- "Select to edit precise time of animation events instead of snapping to nearest frame"),
115
- _controlFrameTime);
126
+ "Select to edit precise time of animation events instead of snapping to nearest frame"
127
+ ),
128
+ _controlFrameTime
129
+ );
116
130
 
117
131
  AnimationClip selectedClip = DrawAndFilterAnimationClips();
118
132
  if (selectedClip == null)
@@ -134,7 +148,11 @@
134
148
  {
135
149
  if (0 <= _selectedFrameIndex)
136
150
  {
137
- _state.Add(new AnimationEventItem(new AnimationEvent { time = _selectedFrameIndex / frameRate }));
151
+ _state.Add(
152
+ new AnimationEventItem(
153
+ new AnimationEvent { time = _selectedFrameIndex / frameRate }
154
+ )
155
+ );
138
156
  }
139
157
  }
140
158
 
@@ -156,13 +174,13 @@
156
174
 
157
175
  EditorGUI.indentLevel++;
158
176
  RenderAnimationEventItem(item, frame, frameRate);
159
-
177
+
160
178
  if (i != stateCopy.Count - 1)
161
179
  {
162
180
  DrawGuiLine(height: 3, color: new Color(0f, 1f, 0.3f, 1f));
163
181
  EditorGUILayout.Space();
164
182
  }
165
-
183
+
166
184
  EditorGUI.indentLevel--;
167
185
  }
168
186
 
@@ -173,14 +191,20 @@
173
191
 
174
192
  private AnimationClip DrawAndFilterAnimationClips()
175
193
  {
176
- _animationSearchString = EditorGUILayout.TextField("Animation Search", _animationSearchString);
177
- List<AnimationClip> animationClips = _sourceAnimator.runtimeAnimatorController.animationClips.ToList();
194
+ _animationSearchString = EditorGUILayout.TextField(
195
+ "Animation Search",
196
+ _animationSearchString
197
+ );
198
+ List<AnimationClip> animationClips =
199
+ _sourceAnimator.runtimeAnimatorController.animationClips.ToList();
178
200
  int selectedIndex;
179
201
  if (string.IsNullOrEmpty(_animationSearchString) || _animationSearchString == "*")
180
202
  {
181
203
  selectedIndex = EditorGUILayout.Popup(
182
- "Animation", animationClips.IndexOf(_currentClip),
183
- animationClips.Select(clip => clip.name).ToArray());
204
+ "Animation",
205
+ animationClips.IndexOf(_currentClip),
206
+ animationClips.Select(clip => clip.name).ToArray()
207
+ );
184
208
  }
185
209
  else
186
210
  {
@@ -212,8 +236,10 @@
212
236
  }
213
237
 
214
238
  selectedIndex = EditorGUILayout.Popup(
215
- "Animation", animationClips.IndexOf(_currentClip),
216
- animationClips.Select(clip => clip.name).ToArray());
239
+ "Animation",
240
+ animationClips.IndexOf(_currentClip),
241
+ animationClips.Select(clip => clip.name).ToArray()
242
+ );
217
243
  }
218
244
 
219
245
  if (selectedIndex < 0)
@@ -243,13 +269,20 @@
243
269
  return 1;
244
270
  }
245
271
 
246
- return AnimationEventEqualityComparer.Instance.Compare(lhs.animationEvent, rhs.animationEvent);
272
+ return AnimationEventEqualityComparer.Instance.Compare(
273
+ lhs.animationEvent,
274
+ rhs.animationEvent
275
+ );
247
276
  }
248
277
 
249
278
  private void DrawControlButtons()
250
279
  {
251
- if (_baseClipEvents.SequenceEqual(
252
- _state.Select(item => item.animationEvent), AnimationEventEqualityComparer.Instance))
280
+ if (
281
+ _baseClipEvents.SequenceEqual(
282
+ _state.Select(item => item.animationEvent),
283
+ AnimationEventEqualityComparer.Instance
284
+ )
285
+ )
253
286
  {
254
287
  GUILayout.Label("No changes detected...");
255
288
  return;
@@ -268,8 +301,14 @@
268
301
  RefreshAnimationEvents();
269
302
  }
270
303
 
271
- if (!_state.SequenceEqual(
272
- _state.OrderBy(item => item.animationEvent, AnimationEventEqualityComparer.Instance)))
304
+ if (
305
+ !_state.SequenceEqual(
306
+ _state.OrderBy(
307
+ item => item.animationEvent,
308
+ AnimationEventEqualityComparer.Instance
309
+ )
310
+ )
311
+ )
273
312
  {
274
313
  if (GUILayout.Button("Re-Order"))
275
314
  {
@@ -284,26 +323,42 @@
284
323
  EditorGUILayout.BeginHorizontal();
285
324
  try
286
325
  {
287
- if (1 <= index && Math.Abs(_state[index - 1].animationEvent.time - item.animationEvent.time) < 0.001f &&
288
- GUILayout.Button("Move Up"))
326
+ if (
327
+ 1 <= index
328
+ && Math.Abs(_state[index - 1].animationEvent.time - item.animationEvent.time)
329
+ < 0.001f
330
+ && GUILayout.Button("Move Up")
331
+ )
289
332
  {
290
333
  _state.RemoveAt(index);
291
334
  _state.Insert(index - 1, item);
292
335
  }
293
336
 
294
- if (index < _state.Count - 1 &&
295
- Math.Abs(_state[index + 1].animationEvent.time - item.animationEvent.time) < 0.001f &&
296
- GUILayout.Button("Move Down"))
337
+ if (
338
+ index < _state.Count - 1
339
+ && Math.Abs(_state[index + 1].animationEvent.time - item.animationEvent.time)
340
+ < 0.001f
341
+ && GUILayout.Button("Move Down")
342
+ )
297
343
  {
298
344
  _state.RemoveAt(index);
299
345
  _state.Insert(index + 1, item);
300
346
  }
301
347
 
302
- if (0 <= index && index < _baseClipEvents.Count &&
303
- !AnimationEventEqualityComparer.Instance.Equals(item.animationEvent, _baseClipEvents[index]) &&
304
- GUILayout.Button("Reset"))
348
+ if (
349
+ 0 <= index
350
+ && index < _baseClipEvents.Count
351
+ && !AnimationEventEqualityComparer.Instance.Equals(
352
+ item.animationEvent,
353
+ _baseClipEvents[index]
354
+ )
355
+ && GUILayout.Button("Reset")
356
+ )
305
357
  {
306
- AnimationEventEqualityComparer.Instance.CopyInto(item.animationEvent, _baseClipEvents[index]);
358
+ AnimationEventEqualityComparer.Instance.CopyInto(
359
+ item.animationEvent,
360
+ _baseClipEvents[index]
361
+ );
307
362
  item.selectedType = null;
308
363
  item.selectedMethod = null;
309
364
  }
@@ -373,7 +428,10 @@
373
428
  private void SelectFunctionName(AnimationEventItem item)
374
429
  {
375
430
  AnimationEvent animEvent = item.animationEvent;
376
- animEvent.functionName = EditorGUILayout.TextField("FunctionName", animEvent.functionName ?? string.Empty);
431
+ animEvent.functionName = EditorGUILayout.TextField(
432
+ "FunctionName",
433
+ animEvent.functionName ?? string.Empty
434
+ );
377
435
  if (!_explicitMode)
378
436
  {
379
437
  item.search = EditorGUILayout.TextField("Search", item.search);
@@ -381,7 +439,9 @@
381
439
  }
382
440
 
383
441
  private void TryPopulateTypeAndMethod(
384
- AnimationEventItem item, IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> lookup)
442
+ AnimationEventItem item,
443
+ IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> lookup
444
+ )
385
445
  {
386
446
  if (item.selectedType != null)
387
447
  {
@@ -389,11 +449,17 @@
389
449
  }
390
450
 
391
451
  AnimationEvent animEvent = item.animationEvent;
392
- foreach (KeyValuePair<Type, IReadOnlyList<MethodInfo>> entry in lookup.OrderBy(kvp => kvp.Key.FullName))
452
+ foreach (
453
+ KeyValuePair<Type, IReadOnlyList<MethodInfo>> entry in lookup.OrderBy(kvp =>
454
+ kvp.Key.FullName
455
+ )
456
+ )
393
457
  {
394
458
  foreach (MethodInfo method in entry.Value)
395
459
  {
396
- if (string.Equals(method.Name, animEvent.functionName, StringComparison.Ordinal))
460
+ if (
461
+ string.Equals(method.Name, animEvent.functionName, StringComparison.Ordinal)
462
+ )
397
463
  {
398
464
  item.selectedType = entry.Key;
399
465
  item.selectedMethod = method;
@@ -403,10 +469,18 @@
403
469
  }
404
470
  }
405
471
 
406
- private bool SelectTypes(AnimationEventItem item, IList<Type> orderedTypes, string[] orderedTypeNames)
472
+ private bool SelectTypes(
473
+ AnimationEventItem item,
474
+ IList<Type> orderedTypes,
475
+ string[] orderedTypeNames
476
+ )
407
477
  {
408
478
  int existingIndex = orderedTypes.IndexOf(item.selectedType);
409
- int selectedTypeIndex = EditorGUILayout.Popup("TypeName", existingIndex, orderedTypeNames);
479
+ int selectedTypeIndex = EditorGUILayout.Popup(
480
+ "TypeName",
481
+ existingIndex,
482
+ orderedTypeNames
483
+ );
410
484
  item.selectedType = selectedTypeIndex < 0 ? null : orderedTypes[selectedTypeIndex];
411
485
  if (existingIndex != selectedTypeIndex)
412
486
  {
@@ -416,7 +490,10 @@
416
490
  return item.selectedType != null;
417
491
  }
418
492
 
419
- private bool SelectMethods(AnimationEventItem item, IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> lookup)
493
+ private bool SelectMethods(
494
+ AnimationEventItem item,
495
+ IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> lookup
496
+ )
420
497
  {
421
498
  AnimationEvent animEvent = item.animationEvent;
422
499
  if (!lookup.TryGetValue(item.selectedType, out IReadOnlyList<MethodInfo> methods))
@@ -428,7 +505,9 @@
428
505
  {
429
506
  foreach (MethodInfo method in methods)
430
507
  {
431
- if (string.Equals(method.Name, animEvent.functionName, StringComparison.Ordinal))
508
+ if (
509
+ string.Equals(method.Name, animEvent.functionName, StringComparison.Ordinal)
510
+ )
432
511
  {
433
512
  item.selectedMethod = method;
434
513
  break;
@@ -442,8 +521,10 @@
442
521
  }
443
522
 
444
523
  int selectedMethodIndex = EditorGUILayout.Popup(
445
- "MethodName", methods.ToList().IndexOf(item.selectedMethod),
446
- methods.Select(method => method.Name).ToArray());
524
+ "MethodName",
525
+ methods.ToList().IndexOf(item.selectedMethod),
526
+ methods.Select(method => method.Name).ToArray()
527
+ );
447
528
  if (0 <= selectedMethodIndex)
448
529
  {
449
530
  item.selectedMethod = methods[selectedMethodIndex];
@@ -465,7 +546,10 @@
465
546
  Type paramType = arrayParameterInfo[0].ParameterType;
466
547
  if (paramType == typeof(int))
467
548
  {
468
- animEvent.intParameter = EditorGUILayout.IntField("IntParameter", animEvent.intParameter);
549
+ animEvent.intParameter = EditorGUILayout.IntField(
550
+ "IntParameter",
551
+ animEvent.intParameter
552
+ );
469
553
  }
470
554
  else if (paramType.BaseType == typeof(Enum))
471
555
  {
@@ -473,52 +557,79 @@
473
557
  List<string> enumNames = enumNamesArray.ToList();
474
558
  string enumName = Enum.GetName(paramType, animEvent.intParameter);
475
559
 
476
- int index = EditorGUILayout.Popup($"{paramType.Name}", enumNames.IndexOf(enumName), enumNamesArray);
560
+ int index = EditorGUILayout.Popup(
561
+ $"{paramType.Name}",
562
+ enumNames.IndexOf(enumName),
563
+ enumNamesArray
564
+ );
477
565
  if (0 <= index)
478
566
  {
479
567
  animEvent.intParameter = (int)Enum.Parse(paramType, enumNames[index]);
480
568
  }
481
569
 
482
- item.overrideEnumValues = EditorGUILayout.Toggle("Override", item.overrideEnumValues);
570
+ item.overrideEnumValues = EditorGUILayout.Toggle(
571
+ "Override",
572
+ item.overrideEnumValues
573
+ );
483
574
  if (item.overrideEnumValues)
484
575
  {
485
- animEvent.intParameter = EditorGUILayout.IntField("IntParameter", animEvent.intParameter);
576
+ animEvent.intParameter = EditorGUILayout.IntField(
577
+ "IntParameter",
578
+ animEvent.intParameter
579
+ );
486
580
  }
487
581
  }
488
582
  else if (paramType == typeof(float))
489
583
  {
490
584
  animEvent.floatParameter = EditorGUILayout.FloatField(
491
- "FloatParameter", animEvent.floatParameter);
585
+ "FloatParameter",
586
+ animEvent.floatParameter
587
+ );
492
588
  }
493
589
  else if (paramType == typeof(string))
494
590
  {
495
591
  animEvent.stringParameter = EditorGUILayout.TextField(
496
- "StringParameter", animEvent.stringParameter);
592
+ "StringParameter",
593
+ animEvent.stringParameter
594
+ );
497
595
  }
498
596
  else if (paramType == typeof(UnityEngine.Object))
499
597
  {
500
598
  animEvent.objectReferenceParameter = EditorGUILayout.ObjectField(
501
- "ObjectReferenceParameter", animEvent.objectReferenceParameter, typeof(UnityEngine.Object),
502
- true);
599
+ "ObjectReferenceParameter",
600
+ animEvent.objectReferenceParameter,
601
+ typeof(UnityEngine.Object),
602
+ true
603
+ );
503
604
  }
504
605
 
505
606
  EditorGUI.indentLevel--;
506
607
  }
507
608
  }
508
609
 
509
- private IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> FilterLookup(AnimationEventItem item)
610
+ private IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> FilterLookup(
611
+ AnimationEventItem item
612
+ )
510
613
  {
511
614
  IReadOnlyDictionary<Type, IReadOnlyList<MethodInfo>> lookup;
512
615
  if (!_explicitMode)
513
616
  {
514
- if (!_lastSeenSearch.TryGetValue(item, out string lastSearch) || !string.Equals(
515
- lastSearch, item.search, StringComparison.InvariantCultureIgnoreCase) ||
516
- !_lookups.TryGetValue(item, out lookup))
617
+ if (
618
+ !_lastSeenSearch.TryGetValue(item, out string lastSearch)
619
+ || !string.Equals(
620
+ lastSearch,
621
+ item.search,
622
+ StringComparison.InvariantCultureIgnoreCase
623
+ )
624
+ || !_lookups.TryGetValue(item, out lookup)
625
+ )
517
626
  {
518
627
  Dictionary<Type, List<MethodInfo>> filtered = Lookup.ToDictionary(
519
- kvp => kvp.Key, kvp => kvp.Value.ToList());
520
- List<string> searchTerms = item.search
521
- .Split(" ")
628
+ kvp => kvp.Key,
629
+ kvp => kvp.Value.ToList()
630
+ );
631
+ List<string> searchTerms = item
632
+ .search.Split(" ")
522
633
  .Select(searchTerm => searchTerm.Trim().ToLowerInvariant())
523
634
  .Where(trimmed => !string.IsNullOrEmpty(trimmed) && trimmed != "*")
524
635
  .ToList();
@@ -534,8 +645,11 @@
534
645
  continue;
535
646
  }
536
647
 
537
- if (entry.Value.Any(
538
- methodInfo => methodInfo.Name.ToLowerInvariant().Contains(searchTerm)))
648
+ if (
649
+ entry.Value.Any(methodInfo =>
650
+ methodInfo.Name.ToLowerInvariant().Contains(searchTerm)
651
+ )
652
+ )
539
653
  {
540
654
  continue;
541
655
  }
@@ -543,12 +657,13 @@
543
657
  _ = filtered.Remove(entry.Key);
544
658
  break;
545
659
  }
546
-
547
660
  }
548
661
  }
549
662
 
550
663
  _lookups[item] = lookup = filtered.ToDictionary(
551
- kvp => kvp.Key, kvp => (IReadOnlyList<MethodInfo>)kvp.Value);
664
+ kvp => kvp.Key,
665
+ kvp => (IReadOnlyList<MethodInfo>)kvp.Value
666
+ );
552
667
  _lastSeenSearch[item] = item.search;
553
668
  }
554
669
  }
@@ -583,7 +698,8 @@
583
698
  return;
584
699
  }
585
700
 
586
- TextureImporter tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
701
+ TextureImporter tImporter =
702
+ AssetImporter.GetAtPath(assetPath) as TextureImporter;
587
703
  if (tImporter == null)
588
704
  {
589
705
  return;
@@ -647,7 +763,10 @@
647
763
  private bool TryFindSpriteForEvent(AnimationEventItem item, out Sprite sprite)
648
764
  {
649
765
  sprite = null;
650
- foreach (ObjectReferenceKeyframe keyFrame in _referenceCurve ?? Enumerable.Empty<ObjectReferenceKeyframe>())
766
+ foreach (
767
+ ObjectReferenceKeyframe keyFrame in _referenceCurve
768
+ ?? Enumerable.Empty<ObjectReferenceKeyframe>()
769
+ )
651
770
  {
652
771
  if (keyFrame.time <= item.animationEvent.time)
653
772
  {
@@ -706,17 +825,17 @@
706
825
  for (int i = 0; i < _currentClip.events.Length; i++)
707
826
  {
708
827
  AnimationEvent animEvent = _currentClip.events[i];
709
- _state.Add(
710
- new AnimationEventItem(animEvent)
711
- {
712
- originalIndex = i
713
- });
828
+ _state.Add(new AnimationEventItem(animEvent) { originalIndex = i });
714
829
  _baseClipEvents.Add(AnimationEventEqualityComparer.Instance.Copy(animEvent));
715
830
  }
716
831
 
717
832
  _selectedFrameIndex = MaxFrameIndex;
718
- _referenceCurve = AnimationUtility.GetObjectReferenceCurve(
719
- _currentClip, EditorCurveBinding.PPtrCurve("", typeof(SpriteRenderer), "m_Sprite")).ToList();
833
+ _referenceCurve = AnimationUtility
834
+ .GetObjectReferenceCurve(
835
+ _currentClip,
836
+ EditorCurveBinding.PPtrCurve("", typeof(SpriteRenderer), "m_Sprite")
837
+ )
838
+ .ToList();
720
839
  _referenceCurve.Sort(
721
840
  (lhs, rhs) =>
722
841
  {
@@ -726,23 +845,31 @@
726
845
  return comparison;
727
846
  }
728
847
 
729
- string lhsName = lhs.value == null ? string.Empty : lhs.value.name ?? string.Empty;
730
- string rhsName = rhs.value == null ? string.Empty : rhs.value.name ?? string.Empty;
848
+ string lhsName =
849
+ lhs.value == null ? string.Empty : lhs.value.name ?? string.Empty;
850
+ string rhsName =
851
+ rhs.value == null ? string.Empty : rhs.value.name ?? string.Empty;
731
852
  return string.Compare(lhsName, rhsName, StringComparison.OrdinalIgnoreCase);
732
- });
853
+ }
854
+ );
733
855
  }
734
856
 
735
857
  private void SaveAnimation()
736
858
  {
737
859
  if (_currentClip != null)
738
860
  {
739
- AnimationUtility.SetAnimationEvents(_currentClip, _state.Select(item => item.animationEvent).ToArray());
861
+ AnimationUtility.SetAnimationEvents(
862
+ _currentClip,
863
+ _state.Select(item => item.animationEvent).ToArray()
864
+ );
740
865
  EditorUtility.SetDirty(_currentClip);
741
866
  AssetDatabase.SaveAssetIfDirty(_currentClip);
742
867
  _baseClipEvents.Clear();
743
868
  foreach (AnimationEventItem item in _state)
744
869
  {
745
- _baseClipEvents.Add(AnimationEventEqualityComparer.Instance.Copy(item.animationEvent));
870
+ _baseClipEvents.Add(
871
+ AnimationEventEqualityComparer.Instance.Copy(item.animationEvent)
872
+ );
746
873
  }
747
874
  }
748
875
  }
@@ -33,8 +33,10 @@
33
33
  if (GUILayout.Button("Set Animator Controller Source Path"))
34
34
  {
35
35
  string sourcePath = EditorUtility.OpenFolderPanel(
36
- "Select Animator Controller Source Path", EditorUtilities.GetCurrentPathOfProjectWindow(),
37
- string.Empty);
36
+ "Select Animator Controller Source Path",
37
+ EditorUtilities.GetCurrentPathOfProjectWindow(),
38
+ string.Empty
39
+ );
38
40
  int assetIndex = sourcePath?.IndexOf("Assets", StringComparison.Ordinal) ?? -1;
39
41
  if (assetIndex < 0)
40
42
  {
@@ -49,8 +51,10 @@
49
51
  if (GUILayout.Button("Set Animator Controller Destination Path"))
50
52
  {
51
53
  string sourcePath = EditorUtility.OpenFolderPanel(
52
- "Select Animator Controller Destination Path", EditorUtilities.GetCurrentPathOfProjectWindow(),
53
- string.Empty);
54
+ "Select Animator Controller Destination Path",
55
+ EditorUtilities.GetCurrentPathOfProjectWindow(),
56
+ string.Empty
57
+ );
54
58
  int assetIndex = sourcePath?.IndexOf("Assets", StringComparison.Ordinal) ?? -1;
55
59
  if (assetIndex < 0)
56
60
  {
@@ -72,14 +76,21 @@
72
76
  return;
73
77
  }
74
78
 
75
- if (string.IsNullOrEmpty(controllerSourcePath) || string.IsNullOrEmpty(controllerDestinationpath))
79
+ if (
80
+ string.IsNullOrEmpty(controllerSourcePath)
81
+ || string.IsNullOrEmpty(controllerDestinationpath)
82
+ )
76
83
  {
77
84
  return;
78
85
  }
79
86
 
80
87
  int processed = 0;
81
- foreach (string assetGuid in AssetDatabase.FindAssets(
82
- "t:AnimatorController", new[] { controllerSourcePath }))
88
+ foreach (
89
+ string assetGuid in AssetDatabase.FindAssets(
90
+ "t:AnimatorController",
91
+ new[] { controllerSourcePath }
92
+ )
93
+ )
83
94
  {
84
95
  string path = AssetDatabase.GUIDToAssetPath(assetGuid);
85
96
 
@@ -87,17 +98,26 @@
87
98
  AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(path);
88
99
  if (animatorController == null)
89
100
  {
90
- this.LogError("Invalid Animator Controller (null) found at path '{0}', skipping.", path);
101
+ this.LogError(
102
+ "Invalid Animator Controller (null) found at path '{0}', skipping.",
103
+ path
104
+ );
91
105
  continue;
92
106
  }
93
107
 
94
108
  string prefix = animatorController.name;
95
109
  string relativePath = path.Substring(controllerSourcePath.Length);
96
- int prefixIndex = relativePath.LastIndexOf(prefix, StringComparison.OrdinalIgnoreCase);
110
+ int prefixIndex = relativePath.LastIndexOf(
111
+ prefix,
112
+ StringComparison.OrdinalIgnoreCase
113
+ );
97
114
  if (prefixIndex < 0)
98
115
  {
99
116
  this.LogWarn(
100
- "Unsupported AnimatorController at '{0}', expected to be prefixed by '{1}'.", path, prefix);
117
+ "Unsupported AnimatorController at '{0}', expected to be prefixed by '{1}'.",
118
+ path,
119
+ prefix
120
+ );
101
121
  continue;
102
122
  }
103
123
 
@@ -109,21 +129,29 @@
109
129
  _ = Directory.CreateDirectory(outputPath);
110
130
  }
111
131
 
112
- string destination = controllerDestinationpath + partialPath + relativePath.Substring(prefixIndex);
132
+ string destination =
133
+ controllerDestinationpath + partialPath + relativePath.Substring(prefixIndex);
113
134
  bool copySuccessful = AssetDatabase.CopyAsset(path, destination);
114
135
  if (copySuccessful)
115
136
  {
116
137
  bool deleteSuccessful = AssetDatabase.DeleteAsset(path);
117
138
  if (!deleteSuccessful)
118
139
  {
119
- this.LogError("Failed to delete Animator Controller asset at path '{0}'.", path);
140
+ this.LogError(
141
+ "Failed to delete Animator Controller asset at path '{0}'.",
142
+ path
143
+ );
120
144
  }
121
145
 
122
146
  ++processed;
123
147
  }
124
148
  else
125
149
  {
126
- this.LogError("Failed to copy Animator Controller from '{0}' to '{1}'.", path, destination);
150
+ this.LogError(
151
+ "Failed to copy Animator Controller from '{0}' to '{1}'.",
152
+ path,
153
+ destination
154
+ );
127
155
  }
128
156
  }
129
157
 
@@ -131,4 +159,4 @@
131
159
  }
132
160
  }
133
161
  #endif
134
- }
162
+ }