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.
- package/.gitattributes +63 -0
- package/CHANGELOG.md +0 -0
- package/CHANGELOG.md.meta +7 -0
- package/Editor/AnimationCreator.cs +218 -0
- package/Editor/AnimationCreator.cs.meta +11 -0
- package/Editor/AnimationEventEditor.cs +742 -0
- package/Editor/AnimationEventEditor.cs.meta +11 -0
- package/Editor/PrefabCheckWizard.cs +140 -0
- package/Editor/PrefabCheckWizard.cs.meta +11 -0
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef +16 -0
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef.meta +7 -0
- package/Editor.meta +8 -0
- package/LICENSE +21 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/LICENSE.meta +7 -0
- package/README.md +2 -0
- package/README.md.meta +7 -0
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs +102 -0
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/AutomaticallyFindAttribute.cs +43 -0
- package/Runtime/Core/Attributes/AutomaticallyFindAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +85 -0
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/KSerializableAttribute.cs +23 -0
- package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/NotNullAttribute.cs +33 -0
- package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ParentComponent.cs +85 -0
- package/Runtime/Core/Attributes/ParentComponent.cs.meta +11 -0
- package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +8 -0
- package/Runtime/Core/Attributes/ReadOnlyAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +14 -0
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -0
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +89 -0
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +66 -0
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes.meta +8 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +91 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +180 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs +274 -0
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs +79 -0
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters.meta +8 -0
- package/Runtime/Core/DataStructure/Circle.cs +50 -0
- package/Runtime/Core/DataStructure/Circle.cs.meta +11 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +130 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -0
- package/Runtime/Core/DataStructure/ISpatialTree.cs +58 -0
- package/Runtime/Core/DataStructure/ISpatialTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/KDTree.cs +186 -0
- package/Runtime/Core/DataStructure/KDTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/QuadTree.cs +184 -0
- package/Runtime/Core/DataStructure/QuadTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/RTree.cs +247 -0
- package/Runtime/Core/DataStructure/RTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/StringWrapper.cs +90 -0
- package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -0
- package/Runtime/Core/DataStructure/TimedCache.cs +50 -0
- package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -0
- package/Runtime/Core/DataStructure.meta +8 -0
- package/Runtime/Core/Extension/AnimatorExtensions.cs +25 -0
- package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/CircleExtensions.cs +25 -0
- package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/ColorExtensions.cs +72 -0
- package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/DictionaryExtensions.cs +173 -0
- package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/DirectionExtensions.cs +210 -0
- package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/HashSetExtensions.cs +12 -0
- package/Runtime/Core/Extension/HashSetExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +109 -0
- package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/IListExtensions.cs +49 -0
- package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/LoggingExtensions.cs +196 -0
- package/Runtime/Core/Extension/LoggingExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/RandomExtensions.cs +110 -0
- package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/StringExtensions.cs +76 -0
- package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/UnityExtensions.cs +1409 -0
- package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension.meta +8 -0
- package/Runtime/Core/Helper/AssignUtilities.cs +14 -0
- package/Runtime/Core/Helper/AssignUtilities.cs.meta +11 -0
- package/Runtime/Core/Helper/Enumerables.cs +17 -0
- package/Runtime/Core/Helper/Enumerables.cs.meta +11 -0
- package/Runtime/Core/Helper/Geometry.cs +26 -0
- package/Runtime/Core/Helper/Geometry.cs.meta +11 -0
- package/Runtime/Core/Helper/Helpers.cs +1092 -0
- package/Runtime/Core/Helper/Helpers.cs.meta +11 -0
- package/Runtime/Core/Helper/IterationHelpers.cs +32 -0
- package/Runtime/Core/Helper/IterationHelpers.cs.meta +11 -0
- package/Runtime/Core/Helper/LifetimeHelpers.cs +12 -0
- package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -0
- package/Runtime/Core/Helper/Objects.cs +447 -0
- package/Runtime/Core/Helper/Objects.cs.meta +11 -0
- package/Runtime/Core/Helper/SpriteHelpers.cs +53 -0
- package/Runtime/Core/Helper/SpriteHelpers.cs.meta +11 -0
- package/Runtime/Core/Helper/StringInList.cs +31 -0
- package/Runtime/Core/Helper/StringInList.cs.meta +11 -0
- package/Runtime/Core/Helper/WallMath.cs +75 -0
- package/Runtime/Core/Helper/WallMath.cs.meta +11 -0
- package/Runtime/Core/Helper.meta +8 -0
- package/Runtime/Core/Math/Line.cs +51 -0
- package/Runtime/Core/Math/Line.cs.meta +11 -0
- package/Runtime/Core/Math/Parabola.cs +44 -0
- package/Runtime/Core/Math/Parabola.cs.meta +11 -0
- package/Runtime/Core/Math/PointPolygonCheck.cs +25 -0
- package/Runtime/Core/Math/PointPolygonCheck.cs.meta +11 -0
- package/Runtime/Core/Math/Range.cs +56 -0
- package/Runtime/Core/Math/Range.cs.meta +11 -0
- package/Runtime/Core/Math/XXHash.cs +308 -0
- package/Runtime/Core/Math/XXHash.cs.meta +11 -0
- package/Runtime/Core/Math.meta +8 -0
- package/Runtime/Core/Model/Direction.cs +26 -0
- package/Runtime/Core/Model/Direction.cs.meta +11 -0
- package/Runtime/Core/Model.meta +8 -0
- package/Runtime/Core/OneOf/FastOneOf.cs +145 -0
- package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -0
- package/Runtime/Core/OneOf/None.cs +6 -0
- package/Runtime/Core/OneOf/None.cs.meta +11 -0
- package/Runtime/Core/OneOf.meta +8 -0
- package/Runtime/Core/Random/AbstractRandom.cs +537 -0
- package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -0
- package/Runtime/Core/Random/IRandom.cs +141 -0
- package/Runtime/Core/Random/IRandom.cs.meta +11 -0
- package/Runtime/Core/Random/NativePcgRandom.cs +97 -0
- package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -0
- package/Runtime/Core/Random/PcgRandom.cs +142 -0
- package/Runtime/Core/Random/PcgRandom.cs.meta +11 -0
- package/Runtime/Core/Random/RandomState.cs +92 -0
- package/Runtime/Core/Random/RandomState.cs.meta +11 -0
- package/Runtime/Core/Random/RandomUtilities.cs +26 -0
- package/Runtime/Core/Random/RandomUtilities.cs.meta +11 -0
- package/Runtime/Core/Random/SquirrelRandom.cs +82 -0
- package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -0
- package/Runtime/Core/Random/SystemRandom.cs +110 -0
- package/Runtime/Core/Random/SystemRandom.cs.meta +11 -0
- package/Runtime/Core/Random/ThreadLocalRandom.cs +11 -0
- package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -0
- package/Runtime/Core/Random/UnityRandom.cs +24 -0
- package/Runtime/Core/Random/UnityRandom.cs.meta +11 -0
- package/Runtime/Core/Random/XorShiftRandom.cs +45 -0
- package/Runtime/Core/Random/XorShiftRandom.cs.meta +11 -0
- package/Runtime/Core/Random.meta +8 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +32 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +32 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters.meta +8 -0
- package/Runtime/Core/Serialization/Serializer.cs +125 -0
- package/Runtime/Core/Serialization/Serializer.cs.meta +11 -0
- package/Runtime/Core/Serialization.meta +8 -0
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +102 -0
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -0
- package/Runtime/Core/Threading.meta +8 -0
- package/Runtime/Core.meta +8 -0
- package/Runtime/Protobuf-Net/System.Buffers.dll +0 -0
- package/Runtime/Protobuf-Net/System.Buffers.dll.meta +33 -0
- package/Runtime/Protobuf-Net/System.Collections.Immutable.dll +0 -0
- package/Runtime/Protobuf-Net/System.Collections.Immutable.dll.meta +33 -0
- package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll +0 -0
- package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll.meta +33 -0
- package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll.meta +33 -0
- package/Runtime/Protobuf-Net/protobuf-net.Core.dll +0 -0
- package/Runtime/Protobuf-Net/protobuf-net.Core.dll.meta +33 -0
- package/Runtime/Protobuf-Net/protobuf-net.dll +0 -0
- package/Runtime/Protobuf-Net/protobuf-net.dll.meta +33 -0
- package/Runtime/Protobuf-Net.meta +8 -0
- package/Runtime/Utils/AnimationEventEqualityComparer.cs +149 -0
- package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -0
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +80 -0
- package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -0
- package/Runtime/Utils/Buffers.cs +32 -0
- package/Runtime/Utils/Buffers.cs.meta +11 -0
- package/Runtime/Utils/CircleLineRenderer.cs +122 -0
- package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -0
- package/Runtime/Utils/Oscillator.cs +25 -0
- package/Runtime/Utils/Oscillator.cs.meta +11 -0
- package/Runtime/Utils/SetTextureImportData.cs +67 -0
- package/Runtime/Utils/SetTextureImportData.cs.meta +11 -0
- package/Runtime/Utils.meta +8 -0
- package/Runtime/WallstopStudios.UnityHelpers.asmdef +14 -0
- package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef +17 -0
- package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef.meta +7 -0
- package/Tests/Editor.meta +8 -0
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +14 -0
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs +14 -0
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +106 -0
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +14 -0
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures.meta +8 -0
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +14 -0
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +14 -0
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +76 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +141 -0
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs.meta +11 -0
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +14 -0
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs.meta +11 -0
- package/Tests/Runtime/Performance.meta +8 -0
- package/Tests/Runtime/Random/PcgRandomTests.cs +9 -0
- package/Tests/Runtime/Random/PcgRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/RandomTestBase.cs +117 -0
- package/Tests/Runtime/Random/RandomTestBase.cs.meta +11 -0
- package/Tests/Runtime/Random/SquirrelRandomTests.cs +9 -0
- package/Tests/Runtime/Random/SquirrelRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/SystemRandomTests.cs +10 -0
- package/Tests/Runtime/Random/SystemRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/UnityRandomTests.cs +9 -0
- package/Tests/Runtime/Random/UnityRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/XorShiftRandomTests.cs +9 -0
- package/Tests/Runtime/Random/XorShiftRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random.meta +8 -0
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef +22 -0
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef.meta +7 -0
- package/Tests/Runtime.meta +8 -0
- package/Tests.meta +8 -0
- package/Third Party Notices.md +1 -0
- package/Third Party Notices.md.meta +7 -0
- package/package.json +35 -0
- 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,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
|
+
}
|