com.wallstop-studios.unity-helpers 1.0.0-rc4

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 (238) hide show
  1. package/.gitattributes +63 -0
  2. package/CHANGELOG.md +0 -0
  3. package/CHANGELOG.md.meta +7 -0
  4. package/Editor/AnimationCreator.cs +218 -0
  5. package/Editor/AnimationCreator.cs.meta +11 -0
  6. package/Editor/AnimationEventEditor.cs +742 -0
  7. package/Editor/AnimationEventEditor.cs.meta +11 -0
  8. package/Editor/PrefabCheckWizard.cs +140 -0
  9. package/Editor/PrefabCheckWizard.cs.meta +11 -0
  10. package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef +16 -0
  11. package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef.meta +7 -0
  12. package/Editor.meta +8 -0
  13. package/LICENSE +21 -0
  14. package/LICENSE.md +7 -0
  15. package/LICENSE.md.meta +7 -0
  16. package/LICENSE.meta +7 -0
  17. package/README.md +2 -0
  18. package/README.md.meta +7 -0
  19. package/Runtime/Core/Attributes/AnimationEventAttribute.cs +102 -0
  20. package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -0
  21. package/Runtime/Core/Attributes/AutomaticallyFindAttribute.cs +43 -0
  22. package/Runtime/Core/Attributes/AutomaticallyFindAttribute.cs.meta +11 -0
  23. package/Runtime/Core/Attributes/ChildComponentAttribute.cs +85 -0
  24. package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -0
  25. package/Runtime/Core/Attributes/KSerializableAttribute.cs +23 -0
  26. package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -0
  27. package/Runtime/Core/Attributes/NotNullAttribute.cs +33 -0
  28. package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -0
  29. package/Runtime/Core/Attributes/ParentComponent.cs +85 -0
  30. package/Runtime/Core/Attributes/ParentComponent.cs.meta +11 -0
  31. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +8 -0
  32. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs.meta +11 -0
  33. package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +14 -0
  34. package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -0
  35. package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +89 -0
  36. package/Runtime/Core/Attributes/SiblingComponentAttribute.cs.meta +11 -0
  37. package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +66 -0
  38. package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs.meta +11 -0
  39. package/Runtime/Core/Attributes.meta +8 -0
  40. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +91 -0
  41. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -0
  42. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +180 -0
  43. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -0
  44. package/Runtime/Core/DataStructure/Adapters/KGuid.cs +274 -0
  45. package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -0
  46. package/Runtime/Core/DataStructure/Adapters/KVector2.cs +79 -0
  47. package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -0
  48. package/Runtime/Core/DataStructure/Adapters.meta +8 -0
  49. package/Runtime/Core/DataStructure/Circle.cs +50 -0
  50. package/Runtime/Core/DataStructure/Circle.cs.meta +11 -0
  51. package/Runtime/Core/DataStructure/CyclicBuffer.cs +130 -0
  52. package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -0
  53. package/Runtime/Core/DataStructure/ISpatialTree.cs +58 -0
  54. package/Runtime/Core/DataStructure/ISpatialTree.cs.meta +11 -0
  55. package/Runtime/Core/DataStructure/KDTree.cs +186 -0
  56. package/Runtime/Core/DataStructure/KDTree.cs.meta +11 -0
  57. package/Runtime/Core/DataStructure/QuadTree.cs +184 -0
  58. package/Runtime/Core/DataStructure/QuadTree.cs.meta +11 -0
  59. package/Runtime/Core/DataStructure/RTree.cs +247 -0
  60. package/Runtime/Core/DataStructure/RTree.cs.meta +11 -0
  61. package/Runtime/Core/DataStructure/StringWrapper.cs +90 -0
  62. package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -0
  63. package/Runtime/Core/DataStructure/TimedCache.cs +50 -0
  64. package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -0
  65. package/Runtime/Core/DataStructure.meta +8 -0
  66. package/Runtime/Core/Extension/AnimatorExtensions.cs +25 -0
  67. package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -0
  68. package/Runtime/Core/Extension/CircleExtensions.cs +25 -0
  69. package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -0
  70. package/Runtime/Core/Extension/ColorExtensions.cs +72 -0
  71. package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -0
  72. package/Runtime/Core/Extension/DictionaryExtensions.cs +173 -0
  73. package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -0
  74. package/Runtime/Core/Extension/DirectionExtensions.cs +210 -0
  75. package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -0
  76. package/Runtime/Core/Extension/HashSetExtensions.cs +12 -0
  77. package/Runtime/Core/Extension/HashSetExtensions.cs.meta +11 -0
  78. package/Runtime/Core/Extension/IEnumerableExtensions.cs +109 -0
  79. package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -0
  80. package/Runtime/Core/Extension/IListExtensions.cs +49 -0
  81. package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -0
  82. package/Runtime/Core/Extension/LoggingExtensions.cs +196 -0
  83. package/Runtime/Core/Extension/LoggingExtensions.cs.meta +11 -0
  84. package/Runtime/Core/Extension/RandomExtensions.cs +110 -0
  85. package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -0
  86. package/Runtime/Core/Extension/StringExtensions.cs +76 -0
  87. package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -0
  88. package/Runtime/Core/Extension/UnityExtensions.cs +1409 -0
  89. package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -0
  90. package/Runtime/Core/Extension.meta +8 -0
  91. package/Runtime/Core/Helper/AssignUtilities.cs +14 -0
  92. package/Runtime/Core/Helper/AssignUtilities.cs.meta +11 -0
  93. package/Runtime/Core/Helper/Enumerables.cs +17 -0
  94. package/Runtime/Core/Helper/Enumerables.cs.meta +11 -0
  95. package/Runtime/Core/Helper/Geometry.cs +26 -0
  96. package/Runtime/Core/Helper/Geometry.cs.meta +11 -0
  97. package/Runtime/Core/Helper/Helpers.cs +1092 -0
  98. package/Runtime/Core/Helper/Helpers.cs.meta +11 -0
  99. package/Runtime/Core/Helper/IterationHelpers.cs +32 -0
  100. package/Runtime/Core/Helper/IterationHelpers.cs.meta +11 -0
  101. package/Runtime/Core/Helper/LifetimeHelpers.cs +12 -0
  102. package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -0
  103. package/Runtime/Core/Helper/Objects.cs +447 -0
  104. package/Runtime/Core/Helper/Objects.cs.meta +11 -0
  105. package/Runtime/Core/Helper/SpriteHelpers.cs +53 -0
  106. package/Runtime/Core/Helper/SpriteHelpers.cs.meta +11 -0
  107. package/Runtime/Core/Helper/StringInList.cs +31 -0
  108. package/Runtime/Core/Helper/StringInList.cs.meta +11 -0
  109. package/Runtime/Core/Helper/WallMath.cs +75 -0
  110. package/Runtime/Core/Helper/WallMath.cs.meta +11 -0
  111. package/Runtime/Core/Helper.meta +8 -0
  112. package/Runtime/Core/Math/Line.cs +51 -0
  113. package/Runtime/Core/Math/Line.cs.meta +11 -0
  114. package/Runtime/Core/Math/Parabola.cs +44 -0
  115. package/Runtime/Core/Math/Parabola.cs.meta +11 -0
  116. package/Runtime/Core/Math/PointPolygonCheck.cs +25 -0
  117. package/Runtime/Core/Math/PointPolygonCheck.cs.meta +11 -0
  118. package/Runtime/Core/Math/Range.cs +56 -0
  119. package/Runtime/Core/Math/Range.cs.meta +11 -0
  120. package/Runtime/Core/Math/XXHash.cs +308 -0
  121. package/Runtime/Core/Math/XXHash.cs.meta +11 -0
  122. package/Runtime/Core/Math.meta +8 -0
  123. package/Runtime/Core/Model/Direction.cs +26 -0
  124. package/Runtime/Core/Model/Direction.cs.meta +11 -0
  125. package/Runtime/Core/Model.meta +8 -0
  126. package/Runtime/Core/OneOf/FastOneOf.cs +145 -0
  127. package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -0
  128. package/Runtime/Core/OneOf/None.cs +6 -0
  129. package/Runtime/Core/OneOf/None.cs.meta +11 -0
  130. package/Runtime/Core/OneOf.meta +8 -0
  131. package/Runtime/Core/Random/AbstractRandom.cs +537 -0
  132. package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -0
  133. package/Runtime/Core/Random/IRandom.cs +141 -0
  134. package/Runtime/Core/Random/IRandom.cs.meta +11 -0
  135. package/Runtime/Core/Random/NativePcgRandom.cs +97 -0
  136. package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -0
  137. package/Runtime/Core/Random/PcgRandom.cs +142 -0
  138. package/Runtime/Core/Random/PcgRandom.cs.meta +11 -0
  139. package/Runtime/Core/Random/RandomState.cs +92 -0
  140. package/Runtime/Core/Random/RandomState.cs.meta +11 -0
  141. package/Runtime/Core/Random/RandomUtilities.cs +26 -0
  142. package/Runtime/Core/Random/RandomUtilities.cs.meta +11 -0
  143. package/Runtime/Core/Random/SquirrelRandom.cs +82 -0
  144. package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -0
  145. package/Runtime/Core/Random/SystemRandom.cs +110 -0
  146. package/Runtime/Core/Random/SystemRandom.cs.meta +11 -0
  147. package/Runtime/Core/Random/ThreadLocalRandom.cs +11 -0
  148. package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -0
  149. package/Runtime/Core/Random/UnityRandom.cs +24 -0
  150. package/Runtime/Core/Random/UnityRandom.cs.meta +11 -0
  151. package/Runtime/Core/Random/XorShiftRandom.cs +45 -0
  152. package/Runtime/Core/Random/XorShiftRandom.cs.meta +11 -0
  153. package/Runtime/Core/Random.meta +8 -0
  154. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +32 -0
  155. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -0
  156. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +32 -0
  157. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -0
  158. package/Runtime/Core/Serialization/JsonConverters.meta +8 -0
  159. package/Runtime/Core/Serialization/Serializer.cs +125 -0
  160. package/Runtime/Core/Serialization/Serializer.cs.meta +11 -0
  161. package/Runtime/Core/Serialization.meta +8 -0
  162. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +102 -0
  163. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -0
  164. package/Runtime/Core/Threading.meta +8 -0
  165. package/Runtime/Core.meta +8 -0
  166. package/Runtime/Protobuf-Net/System.Buffers.dll +0 -0
  167. package/Runtime/Protobuf-Net/System.Buffers.dll.meta +33 -0
  168. package/Runtime/Protobuf-Net/System.Collections.Immutable.dll +0 -0
  169. package/Runtime/Protobuf-Net/System.Collections.Immutable.dll.meta +33 -0
  170. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll +0 -0
  171. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll.meta +33 -0
  172. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  173. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll.meta +33 -0
  174. package/Runtime/Protobuf-Net/protobuf-net.Core.dll +0 -0
  175. package/Runtime/Protobuf-Net/protobuf-net.Core.dll.meta +33 -0
  176. package/Runtime/Protobuf-Net/protobuf-net.dll +0 -0
  177. package/Runtime/Protobuf-Net/protobuf-net.dll.meta +33 -0
  178. package/Runtime/Protobuf-Net.meta +8 -0
  179. package/Runtime/Utils/AnimationEventEqualityComparer.cs +149 -0
  180. package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -0
  181. package/Runtime/Utils/AnimatorEnumStateMachine.cs +80 -0
  182. package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -0
  183. package/Runtime/Utils/Buffers.cs +32 -0
  184. package/Runtime/Utils/Buffers.cs.meta +11 -0
  185. package/Runtime/Utils/CircleLineRenderer.cs +122 -0
  186. package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -0
  187. package/Runtime/Utils/Oscillator.cs +25 -0
  188. package/Runtime/Utils/Oscillator.cs.meta +11 -0
  189. package/Runtime/Utils/SetTextureImportData.cs +67 -0
  190. package/Runtime/Utils/SetTextureImportData.cs.meta +11 -0
  191. package/Runtime/Utils.meta +8 -0
  192. package/Runtime/WallstopStudios.UnityHelpers.asmdef +14 -0
  193. package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -0
  194. package/Runtime.meta +8 -0
  195. package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef +17 -0
  196. package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef.meta +7 -0
  197. package/Tests/Editor.meta +8 -0
  198. package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +14 -0
  199. package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs.meta +11 -0
  200. package/Tests/Runtime/DataStructures/QuadTreeTests.cs +14 -0
  201. package/Tests/Runtime/DataStructures/QuadTreeTests.cs.meta +11 -0
  202. package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +106 -0
  203. package/Tests/Runtime/DataStructures/SpatialTreeTests.cs.meta +11 -0
  204. package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +14 -0
  205. package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs.meta +11 -0
  206. package/Tests/Runtime/DataStructures.meta +8 -0
  207. package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +14 -0
  208. package/Tests/Runtime/Performance/KDTreePerformanceTests.cs.meta +11 -0
  209. package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +14 -0
  210. package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs.meta +11 -0
  211. package/Tests/Runtime/Performance/RandomPerformanceTests.cs +76 -0
  212. package/Tests/Runtime/Performance/RandomPerformanceTests.cs.meta +11 -0
  213. package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +141 -0
  214. package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs.meta +11 -0
  215. package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +14 -0
  216. package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs.meta +11 -0
  217. package/Tests/Runtime/Performance.meta +8 -0
  218. package/Tests/Runtime/Random/PcgRandomTests.cs +9 -0
  219. package/Tests/Runtime/Random/PcgRandomTests.cs.meta +11 -0
  220. package/Tests/Runtime/Random/RandomTestBase.cs +117 -0
  221. package/Tests/Runtime/Random/RandomTestBase.cs.meta +11 -0
  222. package/Tests/Runtime/Random/SquirrelRandomTests.cs +9 -0
  223. package/Tests/Runtime/Random/SquirrelRandomTests.cs.meta +11 -0
  224. package/Tests/Runtime/Random/SystemRandomTests.cs +10 -0
  225. package/Tests/Runtime/Random/SystemRandomTests.cs.meta +11 -0
  226. package/Tests/Runtime/Random/UnityRandomTests.cs +9 -0
  227. package/Tests/Runtime/Random/UnityRandomTests.cs.meta +11 -0
  228. package/Tests/Runtime/Random/XorShiftRandomTests.cs +9 -0
  229. package/Tests/Runtime/Random/XorShiftRandomTests.cs.meta +11 -0
  230. package/Tests/Runtime/Random.meta +8 -0
  231. package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef +22 -0
  232. package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef.meta +7 -0
  233. package/Tests/Runtime.meta +8 -0
  234. package/Tests.meta +8 -0
  235. package/Third Party Notices.md +1 -0
  236. package/Third Party Notices.md.meta +7 -0
  237. package/package.json +35 -0
  238. package/package.json.meta +7 -0
package/.gitattributes ADDED
@@ -0,0 +1,63 @@
1
+ ###############################################################################
2
+ # Set default behavior to automatically normalize line endings.
3
+ ###############################################################################
4
+ * text=auto
5
+
6
+ ###############################################################################
7
+ # Set default behavior for command prompt diff.
8
+ #
9
+ # This is need for earlier builds of msysgit that does not have it on by
10
+ # default for csharp files.
11
+ # Note: This is only used by command line
12
+ ###############################################################################
13
+ #*.cs diff=csharp
14
+
15
+ ###############################################################################
16
+ # Set the merge driver for project and solution files
17
+ #
18
+ # Merging from the command prompt will add diff markers to the files if there
19
+ # are conflicts (Merging from VS is not affected by the settings below, in VS
20
+ # the diff markers are never inserted). Diff markers may cause the following
21
+ # file extensions to fail to load in VS. An alternative would be to treat
22
+ # these files as binary and thus will always conflict and require user
23
+ # intervention with every merge. To do so, just uncomment the entries below
24
+ ###############################################################################
25
+ #*.sln merge=binary
26
+ #*.csproj merge=binary
27
+ #*.vbproj merge=binary
28
+ #*.vcxproj merge=binary
29
+ #*.vcproj merge=binary
30
+ #*.dbproj merge=binary
31
+ #*.fsproj merge=binary
32
+ #*.lsproj merge=binary
33
+ #*.wixproj merge=binary
34
+ #*.modelproj merge=binary
35
+ #*.sqlproj merge=binary
36
+ #*.wwaproj merge=binary
37
+
38
+ ###############################################################################
39
+ # behavior for image files
40
+ #
41
+ # image files are treated as binary by default.
42
+ ###############################################################################
43
+ #*.jpg binary
44
+ #*.png binary
45
+ #*.gif binary
46
+
47
+ ###############################################################################
48
+ # diff behavior for common document formats
49
+ #
50
+ # Convert binary document formats to text before diffing them. This feature
51
+ # is only available from the command line. Turn it on by uncommenting the
52
+ # entries below.
53
+ ###############################################################################
54
+ #*.doc diff=astextplain
55
+ #*.DOC diff=astextplain
56
+ #*.docx diff=astextplain
57
+ #*.DOCX diff=astextplain
58
+ #*.dot diff=astextplain
59
+ #*.DOT diff=astextplain
60
+ #*.pdf diff=astextplain
61
+ #*.PDF diff=astextplain
62
+ #*.rtf diff=astextplain
63
+ #*.RTF diff=astextplain
package/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 1cc2c8be7f7467746a22e8b0a9b7da55
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,218 @@
1
+ namespace UnityHelpers.Editor
2
+ {
3
+ using System;
4
+ using System.Collections.Generic;
5
+ using System.Linq;
6
+ using Core.Extension;
7
+ using UnityEditor;
8
+ using UnityEngine;
9
+ using Object = UnityEngine.Object;
10
+
11
+ [Serializable]
12
+ public sealed class AnimationData
13
+ {
14
+ public const int DefaultFramesPerSecond = 12;
15
+
16
+ public List<Texture2D> frames;
17
+ public int framesPerSecond;
18
+ public string animationName;
19
+ public string assetPath;
20
+
21
+ public AnimationData()
22
+ {
23
+ framesPerSecond = DefaultFramesPerSecond;
24
+ }
25
+ }
26
+
27
+ public sealed class AnimationCreator : ScriptableWizard
28
+ {
29
+ public List<AnimationData> animationData = new() { new AnimationData() };
30
+ public List<Object> animationSources = new();
31
+ public string text;
32
+
33
+ [MenuItem("Tools/Unity Helpers/Animation Creator")]
34
+ public static void CreateAnimation()
35
+ {
36
+ _ = DisplayWizard<AnimationCreator>("Animation Creator", "Create");
37
+ }
38
+
39
+ protected override bool DrawWizardGUI()
40
+ {
41
+ bool returnValue = base.DrawWizardGUI();
42
+
43
+ if (animationData is { Count: 1 })
44
+ {
45
+ AnimationData data = animationData[0];
46
+
47
+ bool filled = false;
48
+ if (data.frames is {Count: 0} && GUILayout.Button("Fill Sprites From Animation Sources"))
49
+ {
50
+ List<string> animationPaths = new();
51
+ foreach (Object animationSource in animationSources)
52
+ {
53
+ string assetPath = AssetDatabase.GetAssetPath(animationSource);
54
+ animationPaths.Add(assetPath);
55
+ }
56
+
57
+ foreach (string assetGuid in AssetDatabase.FindAssets("t:sprite", animationPaths.ToArray()))
58
+ {
59
+ string path = AssetDatabase.GUIDToAssetPath(assetGuid);
60
+ Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
61
+ if (sprite != null && sprite.texture != null)
62
+ {
63
+ data.frames.Add(sprite.texture);
64
+ }
65
+ }
66
+
67
+ filled = true;
68
+ }
69
+
70
+ if (data.frames is { Count: > 0} && (filled || GUILayout.Button("Auto Parse Sprites")))
71
+ {
72
+ Dictionary<string, Dictionary<string, List<Texture2D>>> texturesByPrefixAndAssetPath = new();
73
+ foreach (Texture2D frame in data.frames)
74
+ {
75
+ string assetPathWithFrameName = AssetDatabase.GetAssetPath(frame);
76
+ string frameName = frame.name;
77
+ string assetPath = assetPathWithFrameName.Substring(0, assetPathWithFrameName.LastIndexOf(frameName, StringComparison.Ordinal));
78
+ int lastNumericIndex = frameName.Length - 1;
79
+ for (int i = frameName.Length - 1; 0 <= i; --i)
80
+ {
81
+ if (!char.IsNumber(frameName[i]))
82
+ {
83
+ lastNumericIndex = i + 1;
84
+ break;
85
+ }
86
+ }
87
+
88
+ int lastUnderscoreIndex = frameName.LastIndexOf('_');
89
+ int lastIndex = lastUnderscoreIndex == lastNumericIndex - 1
90
+ ? lastUnderscoreIndex
91
+ : Math.Max(lastUnderscoreIndex, lastNumericIndex);
92
+ if (0 < lastIndex)
93
+ {
94
+ Dictionary<string, List<Texture2D>> texturesByPrefix = texturesByPrefixAndAssetPath.GetOrAdd(assetPath);
95
+ string key = frameName.Substring(0, lastIndex);
96
+ texturesByPrefix.GetOrAdd(key).Add(frame);
97
+ }
98
+ else
99
+ {
100
+ this.LogWarn("Failed to process frame {0}.", frameName);
101
+ }
102
+ }
103
+
104
+ if (0 < texturesByPrefixAndAssetPath.Count)
105
+ {
106
+ animationData.Clear();
107
+ foreach (KeyValuePair<string, Dictionary<string, List<Texture2D>>> assetPathAndTextures in texturesByPrefixAndAssetPath)
108
+ {
109
+ string assetPath = assetPathAndTextures.Key;
110
+ foreach (KeyValuePair<string, List<Texture2D>> textureAndPrefix in assetPathAndTextures.Value)
111
+ {
112
+ AnimationData newData = new()
113
+ {
114
+ frames = textureAndPrefix.Value,
115
+ framesPerSecond = data.framesPerSecond,
116
+ assetPath = assetPath,
117
+ animationName = $"Anim_{textureAndPrefix.Key}"
118
+ };
119
+ animationData.Add(newData);
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ if (animationData is { Count: > 0 } &&
127
+ animationData.Any(data => data.frames is { Count: > 0 }) &&
128
+ !string.IsNullOrWhiteSpace(text))
129
+ {
130
+ if (GUILayout.Button("Append Text To All Animations"))
131
+ {
132
+ foreach (AnimationData data in animationData)
133
+ {
134
+ data.animationName += "_" + text;
135
+ }
136
+ }
137
+
138
+ if (GUILayout.Button("Remove Text From All Animations"))
139
+ {
140
+ foreach (AnimationData data in animationData)
141
+ {
142
+ if (data.animationName.EndsWith(text))
143
+ {
144
+ data.animationName = data.animationName.Remove(data.animationName.Length - text.Length);
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ return returnValue;
151
+ }
152
+
153
+ private void OnWizardCreate()
154
+ {
155
+ if (animationData is not { Count: > 0 })
156
+ {
157
+ return;
158
+ }
159
+
160
+ foreach (AnimationData data in animationData)
161
+ {
162
+ string animationName = data.animationName;
163
+ if (string.IsNullOrWhiteSpace(animationName))
164
+ {
165
+ this.LogWarn("Ignoring animationData without an animation name.");
166
+ continue;
167
+ }
168
+
169
+ int framesPerSecond = data.framesPerSecond;
170
+ if (framesPerSecond <= 0)
171
+ {
172
+ this.LogWarn("Ignoring animationData with FPS of {0} with name {1}.", framesPerSecond, animationName);
173
+ continue;
174
+ }
175
+
176
+ List<Texture2D> frames = data.frames;
177
+ if (frames is not { Count: > 0 })
178
+ {
179
+ this.LogWarn("Ignoring animationData without frames with name {0}.", animationName);
180
+ continue;
181
+ }
182
+
183
+ List<ObjectReferenceKeyframe> keyFrames = new(frames.Count);
184
+
185
+ float currentTime = 0f;
186
+ float timeStep = 1f / framesPerSecond;
187
+ foreach (Texture2D frame in frames)
188
+ {
189
+ Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(AssetDatabase.GetAssetPath(frame));
190
+ if (sprite == null)
191
+ {
192
+ continue;
193
+ }
194
+
195
+ ObjectReferenceKeyframe keyFrame = new() { time = currentTime, value = sprite };
196
+ keyFrames.Add(keyFrame);
197
+
198
+ currentTime += timeStep;
199
+ }
200
+
201
+ if (keyFrames.Count <= 0)
202
+ {
203
+ this.LogWarn("Ignoring animationData with empty frames with name {0}.", animationName);
204
+ continue;
205
+ }
206
+
207
+ AnimationClip animationClip = new();
208
+ AnimationUtility.SetObjectReferenceCurve(
209
+ animationClip,
210
+ EditorCurveBinding.PPtrCurve("", typeof(SpriteRenderer), "m_Sprite"), keyFrames.ToArray());
211
+ string assetPathWithFileNameAndExtension = AssetDatabase.GetAssetPath(frames[0]);
212
+ string assetPath = assetPathWithFileNameAndExtension.Substring(0, assetPathWithFileNameAndExtension.LastIndexOf("/", StringComparison.Ordinal) + 1);
213
+
214
+ ProjectWindowUtil.CreateAsset(animationClip, assetPath + animationName + ".anim");
215
+ }
216
+ }
217
+ }
218
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 7baf6baac1cb4923ad370f1501da39e6
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: