com.wallstop-studios.unity-helpers 2.0.0-rc22 → 2.0.0-rc24

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 (60) 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/README.md +10 -0
  13. package/Runtime/Core/Attributes/AnimationEventAttribute.cs +52 -23
  14. package/Runtime/Core/Attributes/KSerializableAttribute.cs +2 -6
  15. package/Runtime/Core/Attributes/NotNullAttribute.cs +3 -4
  16. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +1 -3
  17. package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +12 -6
  18. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +1 -0
  19. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +13 -8
  20. package/Runtime/Core/DataStructure/Adapters/KGuid.cs +24 -7
  21. package/Runtime/Core/DataStructure/Adapters/KVector2.cs +1 -0
  22. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  23. package/Runtime/Core/DataStructure/CyclicBuffer.cs +45 -49
  24. package/Runtime/Core/DataStructure/ISpatialTree.cs +22 -20
  25. package/Runtime/Core/DataStructure/StringWrapper.cs +1 -0
  26. package/Runtime/Core/Extension/CircleExtensions.cs +2 -2
  27. package/Runtime/Core/Extension/DictionaryExtensions.cs +62 -17
  28. package/Runtime/Core/Extension/StringExtensions.cs +30 -10
  29. package/Runtime/Core/Helper/Enumerables.cs +1 -1
  30. package/Runtime/Core/Helper/LifetimeHelpers.cs +2 -1
  31. package/Runtime/Core/Math/Line.cs +1 -1
  32. package/Runtime/Core/Math/Parabola.cs +4 -2
  33. package/Runtime/Core/Math/PointPolygonCheck.cs +12 -5
  34. package/Runtime/Core/Math/Range.cs +9 -8
  35. package/Runtime/Core/Math/XXHash.cs +22 -20
  36. package/Runtime/Core/Model/Direction.cs +26 -9
  37. package/Runtime/Core/OneOf/FastOneOf.cs +11 -4
  38. package/Runtime/Core/OneOf/None.cs +1 -3
  39. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +13 -4
  40. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +15 -5
  41. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +2 -3
  42. package/Runtime/Utils/AnimationEventEqualityComparer.cs +22 -10
  43. package/Runtime/Utils/AnimatorEnumStateMachine.cs +3 -4
  44. package/Runtime/Utils/Buffers.cs +1 -1
  45. package/Runtime/Utils/CenterPointOffset.cs +1 -2
  46. package/Runtime/Utils/CoroutineHandler.cs +1 -1
  47. package/Runtime/Utils/Oscillator.cs +4 -2
  48. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  49. package/Runtime/Utils/SpriteRendererSyncer.cs +5 -3
  50. package/Runtime/Utils/TextureScale.cs +21 -6
  51. package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +1 -1
  52. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +213 -0
  53. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs.meta +3 -0
  54. package/Tests/Runtime/DataStructures/QuadTreeTests.cs +1 -1
  55. package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +1 -1
  56. package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +41 -21
  57. package/Tests/Runtime/Extensions/StringExtensionTests.cs +1 -1
  58. package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +1 -1
  59. package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +1 -1
  60. package/package.json +3 -2
@@ -17,7 +17,10 @@
17
17
  if (matchColliderToSprite == null)
18
18
  {
19
19
  this.LogError(
20
- "Target was of type {0}, expected {1}.", target?.GetType(), typeof(MatchColliderToSprite));
20
+ "Target was of type {0}, expected {1}.",
21
+ target?.GetType(),
22
+ typeof(MatchColliderToSprite)
23
+ );
21
24
  return;
22
25
  }
23
26
 
@@ -28,4 +31,4 @@
28
31
  }
29
32
  }
30
33
  #endif
31
- }
34
+ }
@@ -18,7 +18,9 @@
18
18
  {
19
19
  private static readonly Dictionary<Type, List<FieldInfo>> FieldsByType = new();
20
20
 
21
- [Tooltip("Drag a folder from Unity here to validate all prefabs under it. Defaults to Assets/Prefabs and Assets/Resources if none specified.")]
21
+ [Tooltip(
22
+ "Drag a folder from Unity here to validate all prefabs under it. Defaults to Assets/Prefabs and Assets/Resources if none specified."
23
+ )]
22
24
  public List<Object> assetPaths;
23
25
 
24
26
  [MenuItem("Tools/Unity Helpers/Prefab Check Wizard")]
@@ -59,7 +61,10 @@
59
61
  }
60
62
  else
61
63
  {
62
- prefab.LogError("Detected missing script for script type {0}.", scriptType);
64
+ prefab.LogError(
65
+ "Detected missing script for script type {0}.",
66
+ scriptType
67
+ );
63
68
  }
64
69
 
65
70
  continue;
@@ -71,17 +76,31 @@
71
76
 
72
77
  private static void ValidateNoNullsInLists(Object component)
73
78
  {
74
- foreach (FieldInfo field in FieldsByType.GetOrAdd(
75
- component.GetType(), type => type
76
- .GetFields(BindingFlags.Instance | BindingFlags.Public)
77
- .Concat(
78
- type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic).Where(
79
- field => field.GetCustomAttributes(typeof(SerializeField)).Any() ||
80
- field.GetCustomAttributes(typeof(ValidateAssignmentAttribute)).Any()))
81
- .Where(field => typeof(IEnumerable).IsAssignableFrom(field.FieldType) || field.FieldType.IsArray)
82
- .Where(field => !typeof(Transform).IsAssignableFrom(field.FieldType))
83
- .Where(field => !typeof(Object).IsAssignableFrom(field.FieldType))
84
- .ToList()))
79
+ foreach (
80
+ FieldInfo field in FieldsByType.GetOrAdd(
81
+ component.GetType(),
82
+ type =>
83
+ type.GetFields(BindingFlags.Instance | BindingFlags.Public)
84
+ .Concat(
85
+ type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
86
+ .Where(field =>
87
+ field.GetCustomAttributes(typeof(SerializeField)).Any()
88
+ || field
89
+ .GetCustomAttributes(
90
+ typeof(ValidateAssignmentAttribute)
91
+ )
92
+ .Any()
93
+ )
94
+ )
95
+ .Where(field =>
96
+ typeof(IEnumerable).IsAssignableFrom(field.FieldType)
97
+ || field.FieldType.IsArray
98
+ )
99
+ .Where(field => !typeof(Transform).IsAssignableFrom(field.FieldType))
100
+ .Where(field => !typeof(Object).IsAssignableFrom(field.FieldType))
101
+ .ToList()
102
+ )
103
+ )
85
104
  {
86
105
  bool LogIfNull(object thing, int? position = null)
87
106
  {
@@ -93,7 +112,11 @@
93
112
  }
94
113
  else
95
114
  {
96
- component.LogError("Field {0} has a null element at position {1}.", field.Name, position);
115
+ component.LogError(
116
+ "Field {0} has a null element at position {1}.",
117
+ field.Name,
118
+ position
119
+ );
97
120
  }
98
121
 
99
122
  return true;
@@ -29,11 +29,13 @@
29
29
  public List<string> spriteFileExtensions = new() { ".png" };
30
30
 
31
31
  [Tooltip(
32
- "Drag various sprite settings here, where the name property matches a sprite asset name. The first settings with an empty or matching name will be applied to each and every sprite.")]
32
+ "Drag various sprite settings here, where the name property matches a sprite asset name. The first settings with an empty or matching name will be applied to each and every sprite."
33
+ )]
33
34
  public List<SpriteSettings> spriteSettings = new() { new SpriteSettings() };
34
35
 
35
36
  [Tooltip(
36
- "Drag a folder from Unity here to apply the configuration to all settings under it. No sprites are modified if no directories are provided.")]
37
+ "Drag a folder from Unity here to apply the configuration to all settings under it. No sprites are modified if no directories are provided."
38
+ )]
37
39
  public List<Object> directories = new();
38
40
 
39
41
  [MenuItem("Tools/Unity Helpers/Sprite Settings Applier")]
@@ -67,14 +69,19 @@
67
69
  continue;
68
70
  }
69
71
 
70
- int index = fullFilePath.LastIndexOf(directoryPath, StringComparison.OrdinalIgnoreCase);
72
+ int index = fullFilePath.LastIndexOf(
73
+ directoryPath,
74
+ StringComparison.OrdinalIgnoreCase
75
+ );
71
76
  if (index < 0)
72
77
  {
73
78
  continue;
74
79
  }
75
80
 
76
81
  string filePath = fullFilePath.Substring(index);
77
- if (processedSpritePaths.Add(fullFilePath) && TryUpdateTextureSettings(filePath))
82
+ if (
83
+ processedSpritePaths.Add(fullFilePath) && TryUpdateTextureSettings(filePath)
84
+ )
78
85
  {
79
86
  ++spriteCount;
80
87
  }
@@ -82,7 +89,10 @@
82
89
 
83
90
  foreach (string subDirectory in Directory.EnumerateDirectories(directoryPath))
84
91
  {
85
- int index = subDirectory.LastIndexOf(directoryPath, StringComparison.OrdinalIgnoreCase);
92
+ int index = subDirectory.LastIndexOf(
93
+ directoryPath,
94
+ StringComparison.OrdinalIgnoreCase
95
+ );
86
96
  if (index < 0)
87
97
  {
88
98
  continue;
@@ -100,7 +110,10 @@
100
110
  }
101
111
 
102
112
  string filePath = AssetDatabase.GetAssetPath(sprite);
103
- if (processedSpritePaths.Add(Application.dataPath + filePath) && TryUpdateTextureSettings(filePath))
113
+ if (
114
+ processedSpritePaths.Add(Application.dataPath + filePath)
115
+ && TryUpdateTextureSettings(filePath)
116
+ )
104
117
  {
105
118
  ++spriteCount;
106
119
  }
@@ -121,8 +134,9 @@
121
134
  return false;
122
135
  }
123
136
 
124
- SpriteSettings spriteData = spriteSettings.FirstOrDefault(
125
- settings => string.IsNullOrEmpty(settings.name) || filePath.Contains(settings.name));
137
+ SpriteSettings spriteData = spriteSettings.FirstOrDefault(settings =>
138
+ string.IsNullOrEmpty(settings.name) || filePath.Contains(settings.name)
139
+ );
126
140
  if (spriteData == null)
127
141
  {
128
142
  return false;
@@ -151,4 +165,4 @@
151
165
  }
152
166
  }
153
167
  #endif
154
- }
168
+ }
@@ -20,14 +20,15 @@
20
20
  public enum ResizeAlgorithm
21
21
  {
22
22
  Bilinear,
23
- Point
23
+ Point,
24
24
  }
25
25
 
26
26
  public List<Texture2D> textures = new();
27
27
 
28
28
  [FormerlySerializedAs("animationSources")]
29
29
  [Tooltip(
30
- "Drag a folder from Unity here to apply the configuration to all textures under it. No textures are modified if no directories are provided.")]
30
+ "Drag a folder from Unity here to apply the configuration to all textures under it. No textures are modified if no directories are provided."
31
+ )]
31
32
  public List<Object> textureSourcePaths = new();
32
33
 
33
34
  public int numResizes = 1;
@@ -61,7 +62,12 @@
61
62
 
62
63
  if (animationPaths.Any())
63
64
  {
64
- foreach (string assetGuid in AssetDatabase.FindAssets("t:texture2D", animationPaths.ToArray()))
65
+ foreach (
66
+ string assetGuid in AssetDatabase.FindAssets(
67
+ "t:texture2D",
68
+ animationPaths.ToArray()
69
+ )
70
+ )
65
71
  {
66
72
  string path = AssetDatabase.GUIDToAssetPath(assetGuid);
67
73
  if (string.IsNullOrEmpty(path))
@@ -94,7 +100,8 @@
94
100
  continue;
95
101
  }
96
102
 
97
- TextureImporter tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
103
+ TextureImporter tImporter =
104
+ AssetImporter.GetAtPath(assetPath) as TextureImporter;
98
105
  if (tImporter == null)
99
106
  {
100
107
  continue;
@@ -112,9 +119,10 @@
112
119
  Texture2D copy = Instantiate(texture);
113
120
  try
114
121
  {
115
- int extraWidth = (int)Math.Round(copy.width / (pixelsPerUnit * widthMultiplier));
116
- int extraHeight = (int)Math.Round(
117
- copy.height / (pixelsPerUnit * heightMultiplier));
122
+ int extraWidth = (int)
123
+ Math.Round(copy.width / (pixelsPerUnit * widthMultiplier));
124
+ int extraHeight = (int)
125
+ Math.Round(copy.height / (pixelsPerUnit * heightMultiplier));
118
126
  if (extraWidth == 0 && extraHeight == 0)
119
127
  {
120
128
  continue;
@@ -123,22 +131,37 @@
123
131
  switch (scalingResizeAlgorithm)
124
132
  {
125
133
  case ResizeAlgorithm.Bilinear:
126
- TextureScale.Bilinear(copy, copy.width + extraWidth, copy.height + extraHeight);
134
+ TextureScale.Bilinear(
135
+ copy,
136
+ copy.width + extraWidth,
137
+ copy.height + extraHeight
138
+ );
127
139
  break;
128
140
  case ResizeAlgorithm.Point:
129
- TextureScale.Point(copy, copy.width + extraWidth, copy.height + extraHeight);
141
+ TextureScale.Point(
142
+ copy,
143
+ copy.width + extraWidth,
144
+ copy.height + extraHeight
145
+ );
130
146
  break;
131
147
  default:
132
148
  throw new InvalidEnumArgumentException(
133
- nameof(scalingResizeAlgorithm), (int)scalingResizeAlgorithm,
134
- typeof(ResizeAlgorithm));
149
+ nameof(scalingResizeAlgorithm),
150
+ (int)scalingResizeAlgorithm,
151
+ typeof(ResizeAlgorithm)
152
+ );
135
153
  }
136
154
 
137
155
  byte[] bytes = copy.EncodeToPNG();
138
156
  File.WriteAllBytes(assetPath, bytes);
139
157
  this.Log(
140
- "Resized {0} from [{1}x{2}] to [{3}x{4}]", texture.name, texture.width, texture.height,
141
- copy.width, copy.height);
158
+ "Resized {0} from [{1}x{2}] to [{3}x{4}]",
159
+ texture.name,
160
+ texture.width,
161
+ texture.height,
162
+ copy.width,
163
+ copy.height
164
+ );
142
165
  }
143
166
  catch (Exception e)
144
167
  {
@@ -155,4 +178,4 @@
155
178
  }
156
179
  }
157
180
  #endif
158
- }
181
+ }
@@ -31,7 +31,8 @@
31
31
  public List<Texture2D> textures = new();
32
32
 
33
33
  [Tooltip(
34
- "Drag a folder from Unity here to apply the configuration to all settings under it. No sprites are modified if no directories are provided.")]
34
+ "Drag a folder from Unity here to apply the configuration to all settings under it. No sprites are modified if no directories are provided."
35
+ )]
35
36
  public List<Object> directories = new();
36
37
 
37
38
  [MenuItem("Tools/Unity Helpers/Texture Settings Applier")]
@@ -54,10 +55,12 @@
54
55
 
55
56
  int textureCount = 0;
56
57
  HashSet<string> processedPaths = new();
57
- foreach (Texture2D texture in textures?
58
- .Distinct()
59
- .OrderBy(texture => texture != null ? texture.name : string.Empty) ??
60
- Enumerable.Empty<Texture2D>())
58
+ foreach (
59
+ Texture2D texture in textures
60
+ ?.Distinct()
61
+ .OrderBy(texture => texture != null ? texture.name : string.Empty)
62
+ ?? Enumerable.Empty<Texture2D>()
63
+ )
61
64
  {
62
65
  if (texture == null)
63
66
  {
@@ -65,7 +68,10 @@
65
68
  }
66
69
 
67
70
  string assetPath = AssetDatabase.GetAssetPath(texture);
68
- if (processedPaths.Add(Application.dataPath + assetPath) && TryUpdateTextureSettings(assetPath))
71
+ if (
72
+ processedPaths.Add(Application.dataPath + assetPath)
73
+ && TryUpdateTextureSettings(assetPath)
74
+ )
69
75
  {
70
76
  ++textureCount;
71
77
  }
@@ -81,7 +87,10 @@
81
87
  continue;
82
88
  }
83
89
 
84
- int index = fullFilePath.LastIndexOf(directoryPath, StringComparison.OrdinalIgnoreCase);
90
+ int index = fullFilePath.LastIndexOf(
91
+ directoryPath,
92
+ StringComparison.OrdinalIgnoreCase
93
+ );
85
94
  if (index < 0)
86
95
  {
87
96
  continue;
@@ -96,7 +105,10 @@
96
105
 
97
106
  foreach (string subDirectory in Directory.EnumerateDirectories(directoryPath))
98
107
  {
99
- int index = subDirectory.LastIndexOf(directoryPath, StringComparison.OrdinalIgnoreCase);
108
+ int index = subDirectory.LastIndexOf(
109
+ directoryPath,
110
+ StringComparison.OrdinalIgnoreCase
111
+ );
100
112
  if (index < 0)
101
113
  {
102
114
  continue;
@@ -129,7 +141,8 @@
129
141
  format = textureFormat,
130
142
  textureCompression = compression,
131
143
  crunchedCompression = useCrunchCompression,
132
- });
144
+ }
145
+ );
133
146
  if (applyReadOnly)
134
147
  {
135
148
  textureImporter.isReadable = !isReadOnly;
@@ -155,4 +168,4 @@
155
168
  }
156
169
  }
157
170
  #endif
158
- }
171
+ }
@@ -11,10 +11,12 @@
11
11
  {
12
12
  Type projectWindowUtilType = typeof(ProjectWindowUtil);
13
13
  MethodInfo getActiveFolderPath = projectWindowUtilType.GetMethod(
14
- "GetActiveFolderPath", BindingFlags.Static | BindingFlags.NonPublic);
14
+ "GetActiveFolderPath",
15
+ BindingFlags.Static | BindingFlags.NonPublic
16
+ );
15
17
  object obj = getActiveFolderPath?.Invoke(null, Array.Empty<object>());
16
18
  return obj?.ToString() ?? string.Empty;
17
19
  }
18
20
  }
19
21
  #endif
20
- }
22
+ }
@@ -9,9 +9,7 @@
9
9
  [CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
10
10
  public sealed class ReadOnlyPropertyDrawer : PropertyDrawer
11
11
  {
12
- public override float GetPropertyHeight(
13
- SerializedProperty property,
14
- GUIContent label)
12
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
15
13
  {
16
14
  return EditorGUI.GetPropertyHeight(property, label, true);
17
15
  }
@@ -25,4 +23,4 @@
25
23
  }
26
24
  }
27
25
  #endif
28
- }
26
+ }
package/README.md CHANGED
@@ -1,2 +1,12 @@
1
1
  # A Grab-Bag
2
2
  Various Unity Helpers. Includes many deterministic, seedable random number generators.
3
+
4
+ # To Install as Unity Package
5
+ 1. Open Unity Package Manager
6
+ 2. (Optional) Enable Pre-release packages to get the latest, cutting-edge builds
7
+ 3. Open the Advanced Package Settings
8
+ 4. Add an entry for a new "Scoped Registry"
9
+ - Name: `NPM`
10
+ - URL: `https://registry.npmjs.org`
11
+ - Scope(s): `com.wallstop-studios.unity-helpers`
12
+ 5. Resolve the latest `com.wallstop-studios.unity-helpers`
@@ -19,7 +19,8 @@
19
19
  static AnimationEventHelpers()
20
20
  {
21
21
  List<(Type, string)> ignoreDerived = new();
22
- Dictionary<Type, List<MethodInfo>> typesToMethods = AppDomain.CurrentDomain.GetAssemblies()
22
+ Dictionary<Type, List<MethodInfo>> typesToMethods = AppDomain
23
+ .CurrentDomain.GetAssemblies()
23
24
  .SelectMany(assembly => assembly.GetTypes())
24
25
  .Where(type => type.IsClass)
25
26
  .Where(type => typeof(MonoBehaviour).IsAssignableFrom(type))
@@ -28,24 +29,39 @@
28
29
  type =>
29
30
  {
30
31
  List<MethodInfo> definedMethods = GetPossibleAnimatorEventsForType(type)
31
- .Where(method => Attribute.IsDefined(method, typeof(AnimationEventAttribute), true)).ToList();
32
+ .Where(method =>
33
+ Attribute.IsDefined(method, typeof(AnimationEventAttribute), true)
34
+ )
35
+ .ToList();
32
36
  foreach (MethodInfo definedMethod in definedMethods)
33
37
  {
34
38
  // Only consider attributes on our specific method
35
- if (!Attribute.IsDefined(definedMethod, typeof(AnimationEventAttribute), false))
39
+ if (
40
+ !Attribute.IsDefined(
41
+ definedMethod,
42
+ typeof(AnimationEventAttribute),
43
+ false
44
+ )
45
+ )
36
46
  {
37
47
  continue;
38
48
  }
39
49
 
40
- if (definedMethod.GetCustomAttributes(typeof(AnimationEventAttribute), false)[0] is
41
- AnimationEventAttribute { ignoreDerived: true })
50
+ if (
51
+ definedMethod.GetCustomAttributes(
52
+ typeof(AnimationEventAttribute),
53
+ false
54
+ )[0]
55
+ is AnimationEventAttribute { ignoreDerived: true }
56
+ )
42
57
  {
43
58
  ignoreDerived.Add((type, definedMethod.Name));
44
59
  }
45
60
  }
46
61
 
47
62
  return definedMethods;
48
- });
63
+ }
64
+ );
49
65
 
50
66
  foreach (KeyValuePair<Type, List<MethodInfo>> entry in typesToMethods.ToList())
51
67
  {
@@ -76,27 +92,40 @@
76
92
  }
77
93
  }
78
94
 
79
- TypesToMethods = typesToMethods.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList<MethodInfo>)kvp.Value);
95
+ TypesToMethods = typesToMethods.ToDictionary(
96
+ kvp => kvp.Key,
97
+ kvp => (IReadOnlyList<MethodInfo>)kvp.Value
98
+ );
80
99
  }
81
100
 
82
101
  public static List<MethodInfo> GetPossibleAnimatorEventsForType(this Type type)
83
102
  {
84
- return type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where
85
- (
86
- p =>
87
- p.ReturnType == typeof(void) &&
88
- (p.GetParameters().Select(q => q.ParameterType).SequenceEqual(new Type[] { }) ||
89
- p.GetParameters().Select(q => q.ParameterType)
90
- .SequenceEqual(new Type[] { typeof(int) }) ||
91
- p.GetParameters().Select(q => q.ParameterType.BaseType)
92
- .SequenceEqual(new Type[] { typeof(Enum) }) ||
93
- p.GetParameters().Select(q => q.ParameterType)
94
- .SequenceEqual(new Type[] { typeof(float) }) ||
95
- p.GetParameters().Select(q => q.ParameterType)
96
- .SequenceEqual(new Type[] { typeof(string) }) ||
97
- p.GetParameters().Select(q => q.ParameterType)
98
- .SequenceEqual(new Type[] { typeof(UnityEngine.Object) }))
99
- ).OrderBy(method => method.Name).ToList();
103
+ return type.GetMethods(
104
+ BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
105
+ )
106
+ .Where(p =>
107
+ p.ReturnType == typeof(void)
108
+ && (
109
+ p.GetParameters().Select(q => q.ParameterType).SequenceEqual(new Type[] { })
110
+ || p.GetParameters()
111
+ .Select(q => q.ParameterType)
112
+ .SequenceEqual(new Type[] { typeof(int) })
113
+ || p.GetParameters()
114
+ .Select(q => q.ParameterType.BaseType)
115
+ .SequenceEqual(new Type[] { typeof(Enum) })
116
+ || p.GetParameters()
117
+ .Select(q => q.ParameterType)
118
+ .SequenceEqual(new Type[] { typeof(float) })
119
+ || p.GetParameters()
120
+ .Select(q => q.ParameterType)
121
+ .SequenceEqual(new Type[] { typeof(string) })
122
+ || p.GetParameters()
123
+ .Select(q => q.ParameterType)
124
+ .SequenceEqual(new Type[] { typeof(UnityEngine.Object) })
125
+ )
126
+ )
127
+ .OrderBy(method => method.Name)
128
+ .ToList();
100
129
  }
101
130
  }
102
131
  }
@@ -8,16 +8,12 @@
8
8
  /// If specified on a class, will automatically attempt to serialize all fields and properties.
9
9
  /// </summary>
10
10
  [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class)]
11
- public sealed class KSerializableAttribute : Attribute
12
- {
13
- }
11
+ public sealed class KSerializableAttribute : Attribute { }
14
12
 
15
13
  /// <summary>
16
14
  /// For classes where KSerializableAttribute is used, specifying this on fields or properties
17
15
  /// will ignore them for the purpose of serialization into SerializedWorld.
18
16
  /// </summary>
19
17
  [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
20
- public sealed class KNonSerializableAttribute : Attribute
21
- {
22
- }
18
+ public sealed class KNonSerializableAttribute : Attribute { }
23
19
  }
@@ -6,16 +6,15 @@
6
6
  using System.Reflection;
7
7
 
8
8
  [AttributeUsage(AttributeTargets.Field)]
9
- public sealed class NotNullAttribute : Attribute
10
- {
11
- }
9
+ public sealed class NotNullAttribute : Attribute { }
12
10
 
13
11
  public static class NotNullAttributeExtensions
14
12
  {
15
13
  public static void CheckForNulls(this object o)
16
14
  {
17
15
  #if UNITY_EDITOR
18
- IEnumerable<FieldInfo> properties = o.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
16
+ IEnumerable<FieldInfo> properties = o.GetType()
17
+ .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
19
18
  .Where(prop => Attribute.IsDefined(prop, typeof(NotNullAttribute)));
20
19
 
21
20
  foreach (FieldInfo field in properties)
@@ -2,7 +2,5 @@
2
2
 
3
3
  namespace UnityHelpers.Core.Attributes
4
4
  {
5
- public sealed class ReadOnlyAttribute : PropertyAttribute
6
- {
7
- }
5
+ public sealed class ReadOnlyAttribute : PropertyAttribute { }
8
6
  }
@@ -21,10 +21,16 @@
21
21
  private static FieldInfo[] GetOrAdd(Type objectType)
22
22
  {
23
23
  return FieldsByType.GetOrAdd(
24
- objectType, type => type
25
- .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
26
- .Where(prop => Attribute.IsDefined(prop, typeof(ValidateAssignmentAttribute)))
27
- .ToArray());
24
+ objectType,
25
+ type =>
26
+ type.GetFields(
27
+ BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
28
+ )
29
+ .Where(prop =>
30
+ Attribute.IsDefined(prop, typeof(ValidateAssignmentAttribute))
31
+ )
32
+ .ToArray()
33
+ );
28
34
  }
29
35
 
30
36
  public static void ValidateAssignments(this Object o)
@@ -88,8 +94,8 @@
88
94
  IList list => list.Count <= 0,
89
95
  ICollection collection => collection.Count <= 0,
90
96
  IEnumerable enumerable => IsInvalid(enumerable),
91
- _ => fieldValue == null
97
+ _ => fieldValue == null,
92
98
  };
93
99
  }
94
100
  }
95
- }
101
+ }
@@ -12,6 +12,7 @@
12
12
  {
13
13
  [ProtoMember(1)]
14
14
  public int x;
15
+
15
16
  [ProtoMember(2)]
16
17
  public int y;
17
18
 
@@ -8,14 +8,19 @@
8
8
 
9
9
  [Serializable]
10
10
  [ProtoContract]
11
- public struct FastVector3Int : IEquatable<FastVector3Int>, IComparable<FastVector3Int>, IComparable
11
+ public struct FastVector3Int
12
+ : IEquatable<FastVector3Int>,
13
+ IComparable<FastVector3Int>,
14
+ IComparable
12
15
  {
13
16
  public static readonly FastVector3Int zero = new(0, 0, 0);
14
17
 
15
18
  [ProtoMember(1)]
16
19
  public int x;
20
+
17
21
  [ProtoMember(2)]
18
22
  public int y;
23
+
19
24
  [ProtoMember(3)]
20
25
  public int z;
21
26
 
@@ -30,13 +35,10 @@
30
35
  }
31
36
 
32
37
  public FastVector3Int(Vector3Int vector)
33
- : this(vector.x, vector.y, vector.z)
34
- {
35
- }
38
+ : this(vector.x, vector.y, vector.z) { }
36
39
 
37
- public FastVector3Int(int x, int y) : this(x, y, 0)
38
- {
39
- }
40
+ public FastVector3Int(int x, int y)
41
+ : this(x, y, 0) { }
40
42
 
41
43
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
42
44
  public static bool operator ==(FastVector3Int lhs, FastVector3Int rhs)
@@ -124,7 +126,10 @@
124
126
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
125
127
  public bool Equals(FastVector3Int other)
126
128
  {
127
- return GetHashCode() == other.GetHashCode() && x == other.x && y == other.y && z == other.z;
129
+ return GetHashCode() == other.GetHashCode()
130
+ && x == other.x
131
+ && y == other.y
132
+ && z == other.z;
128
133
  }
129
134
 
130
135
  [MethodImpl(MethodImplOptions.AggressiveInlining)]