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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
namespace UnityHelpers.Utils
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
public sealed class AnimationEventEqualityComparer : EqualityComparer<AnimationEvent>, IComparer<AnimationEvent>
|
|
8
|
+
{
|
|
9
|
+
public static readonly AnimationEventEqualityComparer Instance = new();
|
|
10
|
+
|
|
11
|
+
private AnimationEventEqualityComparer()
|
|
12
|
+
{
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Returns a shallow copy with equatable values propagated
|
|
17
|
+
public AnimationEvent Copy(AnimationEvent instance)
|
|
18
|
+
{
|
|
19
|
+
if (instance == null)
|
|
20
|
+
{
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
AnimationEvent copy = new();
|
|
25
|
+
CopyInto(copy, instance);
|
|
26
|
+
return copy;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public void CopyInto(AnimationEvent into, AnimationEvent parameters)
|
|
30
|
+
{
|
|
31
|
+
if (into == null || parameters == null)
|
|
32
|
+
{
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
into.time = parameters.time;
|
|
37
|
+
into.functionName = parameters.functionName;
|
|
38
|
+
into.intParameter = parameters.intParameter;
|
|
39
|
+
into.floatParameter = parameters.floatParameter;
|
|
40
|
+
into.stringParameter = parameters.stringParameter;
|
|
41
|
+
into.objectReferenceParameter = parameters.objectReferenceParameter;
|
|
42
|
+
into.messageOptions = parameters.messageOptions;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public override bool Equals(AnimationEvent lhs, AnimationEvent rhs)
|
|
46
|
+
{
|
|
47
|
+
if (ReferenceEquals(lhs, rhs))
|
|
48
|
+
{
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (lhs == null || rhs == null)
|
|
53
|
+
{
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
|
58
|
+
if (lhs.time != rhs.time)
|
|
59
|
+
{
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (lhs.functionName != rhs.functionName)
|
|
64
|
+
{
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (lhs.intParameter != rhs.intParameter)
|
|
69
|
+
{
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
|
74
|
+
if (lhs.floatParameter != rhs.floatParameter)
|
|
75
|
+
{
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (lhs.stringParameter != rhs.stringParameter)
|
|
80
|
+
{
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (lhs.objectReferenceParameter != rhs.objectReferenceParameter)
|
|
85
|
+
{
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (lhs.messageOptions != rhs.messageOptions)
|
|
90
|
+
{
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
public override int GetHashCode(AnimationEvent instance)
|
|
99
|
+
{
|
|
100
|
+
return HashCode.Combine(
|
|
101
|
+
instance.time, instance.functionName, instance.intParameter, instance.floatParameter,
|
|
102
|
+
instance.stringParameter, instance.objectReferenceParameter, instance.messageOptions);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public int Compare(AnimationEvent lhs, AnimationEvent rhs)
|
|
106
|
+
{
|
|
107
|
+
if (ReferenceEquals(lhs, rhs))
|
|
108
|
+
{
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (ReferenceEquals(null, rhs))
|
|
113
|
+
{
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (ReferenceEquals(null, lhs))
|
|
118
|
+
{
|
|
119
|
+
return -1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
int timeComparison = lhs.time.CompareTo(rhs.time);
|
|
123
|
+
if (timeComparison != 0)
|
|
124
|
+
{
|
|
125
|
+
return timeComparison;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
int functionNameComparison = string.Compare(lhs.functionName, rhs.functionName, StringComparison.Ordinal);
|
|
129
|
+
if (functionNameComparison != 0)
|
|
130
|
+
{
|
|
131
|
+
return functionNameComparison;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
int intParameterComparison = lhs.intParameter.CompareTo(rhs.intParameter);
|
|
135
|
+
if (intParameterComparison != 0)
|
|
136
|
+
{
|
|
137
|
+
return intParameterComparison;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
int stringParameterComparison = string.Compare(lhs.stringParameter, rhs.stringParameter, StringComparison.Ordinal);
|
|
141
|
+
if (stringParameterComparison != 0)
|
|
142
|
+
{
|
|
143
|
+
return stringParameterComparison;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return lhs.floatParameter.CompareTo(rhs.floatParameter);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
namespace UnityHelpers.Utils
|
|
2
|
+
{
|
|
3
|
+
using Core.Extension;
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Globalization;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using System.Runtime.Serialization;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Maps & manages an enum parameter to bool Animator parameters.
|
|
13
|
+
/// </summary>
|
|
14
|
+
/// <typeparam name="T">Specific Enum being managed.</typeparam>
|
|
15
|
+
[DataContract]
|
|
16
|
+
public sealed class AnimatorEnumStateMachine<T>
|
|
17
|
+
where T : struct, IConvertible, IComparable,
|
|
18
|
+
IFormattable // This is as close as we can get to saying where T : Enum (https://stackoverflow.com/questions/79126/create-generic-method-constraining-t-to-an-enum)
|
|
19
|
+
{
|
|
20
|
+
private static readonly T[] Values = Enum.GetValues(typeof(T)).OfType<T>().ToArray();
|
|
21
|
+
|
|
22
|
+
[IgnoreDataMember] private readonly HashSet<string> _availableBools = new HashSet<string>();
|
|
23
|
+
|
|
24
|
+
[IgnoreDataMember] public readonly Animator Animator;
|
|
25
|
+
|
|
26
|
+
[IgnoreDataMember] private T _value;
|
|
27
|
+
|
|
28
|
+
[DataMember]
|
|
29
|
+
public T Value
|
|
30
|
+
{
|
|
31
|
+
get { return _value; }
|
|
32
|
+
set
|
|
33
|
+
{
|
|
34
|
+
foreach (T possibleValue in Values)
|
|
35
|
+
{
|
|
36
|
+
string valueName = possibleValue.ToString(CultureInfo.InvariantCulture);
|
|
37
|
+
if (_availableBools.Contains(valueName))
|
|
38
|
+
{
|
|
39
|
+
Animator.SetBool(valueName, Equals(value, possibleValue));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_value = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[DataMember]
|
|
48
|
+
private string Type => typeof(T).Name;
|
|
49
|
+
|
|
50
|
+
public AnimatorEnumStateMachine(Animator animator, T defaultValue = default(T))
|
|
51
|
+
{
|
|
52
|
+
if (animator == null)
|
|
53
|
+
{
|
|
54
|
+
throw new ArgumentNullException(nameof(animator));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Animator = animator;
|
|
58
|
+
|
|
59
|
+
foreach (AnimatorControllerParameter parameter in Animator.parameters)
|
|
60
|
+
{
|
|
61
|
+
switch (parameter.type)
|
|
62
|
+
{
|
|
63
|
+
case AnimatorControllerParameterType.Bool:
|
|
64
|
+
case AnimatorControllerParameterType.Trigger:
|
|
65
|
+
_availableBools.Add(parameter.name);
|
|
66
|
+
continue;
|
|
67
|
+
default:
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_value = defaultValue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public override string ToString()
|
|
76
|
+
{
|
|
77
|
+
return this.ToJson();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
namespace UnityHelpers.Utils
|
|
2
|
+
{
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
public static class Buffers
|
|
7
|
+
{
|
|
8
|
+
public const int BufferSize = 10_000;
|
|
9
|
+
|
|
10
|
+
public static readonly HashSet<Collider2D> UniqueColliders = new();
|
|
11
|
+
public static readonly Collider2D[] Colliders = new Collider2D[BufferSize];
|
|
12
|
+
public static readonly RaycastHit2D[] RaycastHits = new RaycastHit2D[BufferSize];
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
Note: Only use with CONSTANT time values, otherwise this is a memory leak.
|
|
16
|
+
DO NOT USE with random values.
|
|
17
|
+
*/
|
|
18
|
+
public static readonly Dictionary<float, WaitForSeconds> WaitForSeconds = new();
|
|
19
|
+
public static readonly System.Random Random = new();
|
|
20
|
+
public static readonly WaitForFixedUpdate WaitForFixedUpdate = new();
|
|
21
|
+
public static readonly WaitForEndOfFrame WaitForEndOfFrame = new();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static class Buffers<T>
|
|
25
|
+
{
|
|
26
|
+
public static readonly List<T> List = new();
|
|
27
|
+
public static readonly HashSet<T> HashSet = new();
|
|
28
|
+
public static readonly Queue<T> Queue = new();
|
|
29
|
+
public static readonly Stack<T> Stack = new();
|
|
30
|
+
public static readonly LinkedList<T> LinkedList = new();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
namespace UnityHelpers.Utils
|
|
2
|
+
{
|
|
3
|
+
using Core.Attributes;
|
|
4
|
+
using Core.Extension;
|
|
5
|
+
using Core.Helper;
|
|
6
|
+
using Core.Random;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
|
|
9
|
+
[RequireComponent(typeof(LineRenderer))]
|
|
10
|
+
[RequireComponent(typeof(CircleCollider2D))]
|
|
11
|
+
[DisallowMultipleComponent]
|
|
12
|
+
public sealed class CircleLineRenderer : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
public float minLineWidth = 0.005f;
|
|
15
|
+
public float maxLineWidth = 0.02f;
|
|
16
|
+
public int numSegments = 4;
|
|
17
|
+
public int baseSegments = 4;
|
|
18
|
+
public float updateRateSeconds = 0.1f;
|
|
19
|
+
public Color color = Color.grey;
|
|
20
|
+
|
|
21
|
+
public Vector3 Offset
|
|
22
|
+
{
|
|
23
|
+
get => _offset;
|
|
24
|
+
set => transform.localPosition = _offset = value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[SiblingComponent]
|
|
28
|
+
private CircleCollider2D _collider;
|
|
29
|
+
[SiblingComponent]
|
|
30
|
+
private LineRenderer[] _lineRenderers;
|
|
31
|
+
|
|
32
|
+
private Vector3 _offset;
|
|
33
|
+
|
|
34
|
+
private Coroutine _update;
|
|
35
|
+
|
|
36
|
+
private void Awake()
|
|
37
|
+
{
|
|
38
|
+
this.AssignSiblingComponents();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private void OnEnable()
|
|
42
|
+
{
|
|
43
|
+
if (_update != null)
|
|
44
|
+
{
|
|
45
|
+
StopCoroutine(_update);
|
|
46
|
+
}
|
|
47
|
+
_update = this.StartFunctionAsCoroutine(Render, updateRateSeconds);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private void OnDisable()
|
|
51
|
+
{
|
|
52
|
+
if (_update != null)
|
|
53
|
+
{
|
|
54
|
+
StopCoroutine(_update);
|
|
55
|
+
_update = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private void OnValidate()
|
|
60
|
+
{
|
|
61
|
+
if (numSegments <= 2)
|
|
62
|
+
{
|
|
63
|
+
this.LogWarn("Invalid number of segments {0}.", numSegments);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (updateRateSeconds <= 0)
|
|
67
|
+
{
|
|
68
|
+
this.LogWarn("Invalid update rate {0}.", updateRateSeconds);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (maxLineWidth < minLineWidth)
|
|
72
|
+
{
|
|
73
|
+
this.LogWarn("MaxLineWidth {0} smaller than MinLineWidth {1}.", maxLineWidth, minLineWidth);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private void Update()
|
|
78
|
+
{
|
|
79
|
+
foreach (LineRenderer lineRenderer in _lineRenderers)
|
|
80
|
+
{
|
|
81
|
+
lineRenderer.enabled = _collider.enabled;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private void Render()
|
|
86
|
+
{
|
|
87
|
+
foreach (LineRenderer lineRenderer in _lineRenderers)
|
|
88
|
+
{
|
|
89
|
+
if (!lineRenderer.enabled)
|
|
90
|
+
{
|
|
91
|
+
lineRenderer.positionCount = 0;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
lineRenderer.startColor = color;
|
|
96
|
+
lineRenderer.endColor = color;
|
|
97
|
+
lineRenderer.loop = true;
|
|
98
|
+
lineRenderer.positionCount = numSegments;
|
|
99
|
+
|
|
100
|
+
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
|
101
|
+
float lineWidth = minLineWidth == maxLineWidth ? minLineWidth : PcgRandom.Instance.NextFloat(minLineWidth, maxLineWidth);
|
|
102
|
+
|
|
103
|
+
lineRenderer.startWidth = lineWidth;
|
|
104
|
+
lineRenderer.endWidth = lineWidth;
|
|
105
|
+
lineRenderer.useWorldSpace = false; // All below positions are local space
|
|
106
|
+
float distanceMultiplier = _collider.radius;
|
|
107
|
+
|
|
108
|
+
float angle = 360f / numSegments;
|
|
109
|
+
float offsetRadians = PcgRandom.Instance.NextFloat(angle);
|
|
110
|
+
float currentOffset = offsetRadians;
|
|
111
|
+
Vector3[] positions = new Vector3[numSegments];
|
|
112
|
+
for (int i = 0; i < numSegments; ++i)
|
|
113
|
+
{
|
|
114
|
+
positions[i] = new Vector3(Mathf.Cos(Mathf.Deg2Rad * currentOffset), Mathf.Sin(Mathf.Deg2Rad * currentOffset)) * distanceMultiplier;
|
|
115
|
+
currentOffset += angle % 360f;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
lineRenderer.SetPositions(positions);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
namespace UnityHelpers.Utils
|
|
2
|
+
{
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
[DisallowMultipleComponent]
|
|
6
|
+
public sealed class Oscillator : MonoBehaviour
|
|
7
|
+
{
|
|
8
|
+
public float speed = 1f;
|
|
9
|
+
public float width = 1f;
|
|
10
|
+
public float height = 1f;
|
|
11
|
+
|
|
12
|
+
private Vector3 _initialLocalPosition;
|
|
13
|
+
|
|
14
|
+
private void Awake()
|
|
15
|
+
{
|
|
16
|
+
_initialLocalPosition = transform.localPosition;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private void Update()
|
|
20
|
+
{
|
|
21
|
+
float time = Time.time;
|
|
22
|
+
transform.localPosition = _initialLocalPosition + new Vector3(Mathf.Cos(time * speed) * width, Mathf.Sin(time * speed) * height);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
namespace UnityHelpers.Utils
|
|
2
|
+
{
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
public static class SetTextureImportData
|
|
7
|
+
{
|
|
8
|
+
public const int MaxTextureSize = 8192;
|
|
9
|
+
public const int RegularTextureSize = 2048;
|
|
10
|
+
|
|
11
|
+
public static void SetReadable(Texture2D texture)
|
|
12
|
+
{
|
|
13
|
+
#if UNITY_EDITOR
|
|
14
|
+
|
|
15
|
+
string assetPath = AssetDatabase.GetAssetPath(texture);
|
|
16
|
+
if (string.IsNullOrEmpty(assetPath))
|
|
17
|
+
{
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
TextureImporter tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
|
21
|
+
|
|
22
|
+
if (tImporter == null)
|
|
23
|
+
{
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
tImporter.isReadable = true;
|
|
28
|
+
tImporter.SaveAndReimport();
|
|
29
|
+
#endif
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static void SetTextureImporterFormat(Texture2D texture, bool isReadable = true)
|
|
33
|
+
{
|
|
34
|
+
#if UNITY_EDITOR
|
|
35
|
+
if (texture == null)
|
|
36
|
+
{
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
string assetPath = AssetDatabase.GetAssetPath(texture);
|
|
41
|
+
if (string.IsNullOrEmpty(assetPath))
|
|
42
|
+
{
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
TextureImporter tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
|
46
|
+
|
|
47
|
+
if (tImporter == null)
|
|
48
|
+
{
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
tImporter.isReadable = isReadable;
|
|
53
|
+
|
|
54
|
+
TextureImporterPlatformSettings importerSettings = new TextureImporterPlatformSettings
|
|
55
|
+
{
|
|
56
|
+
resizeAlgorithm = TextureResizeAlgorithm.Bilinear,
|
|
57
|
+
maxTextureSize = MaxTextureSize,
|
|
58
|
+
format = TextureImporterFormat.Automatic,
|
|
59
|
+
textureCompression = TextureImporterCompression.Uncompressed,
|
|
60
|
+
};
|
|
61
|
+
tImporter.SetPlatformTextureSettings(importerSettings);
|
|
62
|
+
|
|
63
|
+
tImporter.SaveAndReimport();
|
|
64
|
+
# endif
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.UnityHelpers",
|
|
3
|
+
"rootNamespace": "UnityHelpers",
|
|
4
|
+
"references": [],
|
|
5
|
+
"includePlatforms": [],
|
|
6
|
+
"excludePlatforms": [],
|
|
7
|
+
"allowUnsafeCode": true,
|
|
8
|
+
"overrideReferences": false,
|
|
9
|
+
"precompiledReferences": [],
|
|
10
|
+
"autoReferenced": true,
|
|
11
|
+
"defineConstraints": [],
|
|
12
|
+
"versionDefines": [],
|
|
13
|
+
"noEngineReferences": false
|
|
14
|
+
}
|
package/Runtime.meta
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.UnityHelpers.Tests.Editor",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"UnityEditor.TestRunner",
|
|
6
|
+
"UnityEngine.TestRunner"
|
|
7
|
+
],
|
|
8
|
+
"includePlatforms": [],
|
|
9
|
+
"excludePlatforms": [],
|
|
10
|
+
"allowUnsafeCode": false,
|
|
11
|
+
"overrideReferences": false,
|
|
12
|
+
"precompiledReferences": [],
|
|
13
|
+
"autoReferenced": true,
|
|
14
|
+
"defineConstraints": [],
|
|
15
|
+
"versionDefines": [],
|
|
16
|
+
"noEngineReferences": false
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
namespace UnityHelpers.Tests.DataStructures
|
|
2
|
+
{
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using Core.DataStructure;
|
|
6
|
+
|
|
7
|
+
public sealed class BalancedKDTreeTests : SpatialTreeTests<KDTree<Vector2>>
|
|
8
|
+
{
|
|
9
|
+
protected override KDTree<Vector2> CreateTree(IEnumerable<Vector2> points)
|
|
10
|
+
{
|
|
11
|
+
return new KDTree<Vector2>(points, _ => _, balanced: true);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
namespace UnityHelpers.Tests.DataStructures
|
|
2
|
+
{
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using Core.DataStructure;
|
|
6
|
+
|
|
7
|
+
public sealed class QuadTreeTests : SpatialTreeTests<QuadTree<Vector2>>
|
|
8
|
+
{
|
|
9
|
+
protected override QuadTree<Vector2> CreateTree(IEnumerable<Vector2> points)
|
|
10
|
+
{
|
|
11
|
+
return new QuadTree<Vector2>(points, _ => _);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|