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.
- 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/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
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
if (matchColliderToSprite == null)
|
|
18
18
|
{
|
|
19
19
|
this.LogError(
|
|
20
|
-
"Target was of type {0}, expected {1}.",
|
|
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(
|
|
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(
|
|
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 (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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(
|
|
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(
|
|
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 (
|
|
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(
|
|
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 (
|
|
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
|
-
|
|
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 (
|
|
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 =
|
|
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)
|
|
116
|
-
|
|
117
|
-
|
|
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(
|
|
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(
|
|
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),
|
|
134
|
-
|
|
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}]",
|
|
141
|
-
|
|
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 (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 (
|
|
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(
|
|
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(
|
|
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",
|
|
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
|
+
}
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
static AnimationEventHelpers()
|
|
20
20
|
{
|
|
21
21
|
List<(Type, string)> ignoreDerived = new();
|
|
22
|
-
Dictionary<Type, List<MethodInfo>> typesToMethods = AppDomain
|
|
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 =>
|
|
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 (
|
|
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 (
|
|
41
|
-
|
|
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(
|
|
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(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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()
|
|
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)
|
|
@@ -21,10 +21,16 @@
|
|
|
21
21
|
private static FieldInfo[] GetOrAdd(Type objectType)
|
|
22
22
|
{
|
|
23
23
|
return FieldsByType.GetOrAdd(
|
|
24
|
-
objectType,
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
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
|
+
}
|
|
@@ -8,14 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
[Serializable]
|
|
10
10
|
[ProtoContract]
|
|
11
|
-
public struct FastVector3Int
|
|
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)
|
|
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()
|
|
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)]
|