com.wallstop-studios.unity-helpers 2.0.0-rc79.8 → 2.0.0-rc80
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.
|
@@ -17,6 +17,7 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
|
17
17
|
Labels = 1 << 1,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
[Flags]
|
|
20
21
|
public enum LabelSelectionMode
|
|
21
22
|
{
|
|
22
23
|
[Obsolete("Please select a valid value")]
|
|
@@ -25,6 +26,7 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
|
25
26
|
AnyOf = 1 << 1,
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
[Flags]
|
|
28
30
|
public enum SpriteSelectionBooleanLogic
|
|
29
31
|
{
|
|
30
32
|
[Obsolete("Please select a valid value")]
|
|
@@ -142,6 +144,10 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
|
142
144
|
[IntDropdown(0, 2, 4, 8, 16, 32)]
|
|
143
145
|
public int padding = 4;
|
|
144
146
|
|
|
147
|
+
public bool enableTightPacking = true;
|
|
148
|
+
|
|
149
|
+
public bool enableAlphaDilation = false;
|
|
150
|
+
|
|
145
151
|
[Tooltip(
|
|
146
152
|
"Enable Read/Write on the generated atlas texture. Needed for some runtime operations, but increases memory."
|
|
147
153
|
)]
|
|
@@ -782,6 +782,8 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
|
|
|
782
782
|
SpriteAtlasPackingSettings packingSettings = atlas.GetPackingSettings();
|
|
783
783
|
packingSettings.enableRotation = config.enableRotation;
|
|
784
784
|
packingSettings.padding = config.padding;
|
|
785
|
+
packingSettings.enableTightPacking = config.enableTightPacking;
|
|
786
|
+
packingSettings.enableAlphaDilation = config.enableAlphaDilation;
|
|
785
787
|
atlas.SetPackingSettings(packingSettings);
|
|
786
788
|
|
|
787
789
|
SpriteAtlasTextureSettings textureSettings = atlas.GetTextureSettings();
|
|
@@ -407,9 +407,79 @@ namespace WallstopStudios.UnityHelpers.Core.Random
|
|
|
407
407
|
{
|
|
408
408
|
return NextOf(list);
|
|
409
409
|
}
|
|
410
|
-
|
|
411
410
|
int index = Next(collection.Count);
|
|
412
|
-
|
|
411
|
+
|
|
412
|
+
switch (collection)
|
|
413
|
+
{
|
|
414
|
+
case HashSet<T> hashSet:
|
|
415
|
+
{
|
|
416
|
+
int i = 0;
|
|
417
|
+
foreach (T element in hashSet)
|
|
418
|
+
{
|
|
419
|
+
if (index == i++)
|
|
420
|
+
{
|
|
421
|
+
return element;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
throw new ArgumentException(nameof(collection));
|
|
425
|
+
}
|
|
426
|
+
case SortedSet<T> sortedSet:
|
|
427
|
+
{
|
|
428
|
+
int i = 0;
|
|
429
|
+
foreach (T element in sortedSet)
|
|
430
|
+
{
|
|
431
|
+
if (index == i++)
|
|
432
|
+
{
|
|
433
|
+
return element;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
throw new ArgumentException(nameof(collection));
|
|
438
|
+
}
|
|
439
|
+
case LinkedList<T> linkedList:
|
|
440
|
+
{
|
|
441
|
+
int i = 0;
|
|
442
|
+
foreach (T element in linkedList)
|
|
443
|
+
{
|
|
444
|
+
if (index == i++)
|
|
445
|
+
{
|
|
446
|
+
return element;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
throw new ArgumentException(nameof(collection));
|
|
451
|
+
}
|
|
452
|
+
case Queue<T> queue:
|
|
453
|
+
{
|
|
454
|
+
int i = 0;
|
|
455
|
+
foreach (T element in queue)
|
|
456
|
+
{
|
|
457
|
+
if (index == i++)
|
|
458
|
+
{
|
|
459
|
+
return element;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
throw new ArgumentException(nameof(collection));
|
|
464
|
+
}
|
|
465
|
+
case Stack<T> stack:
|
|
466
|
+
{
|
|
467
|
+
int i = 0;
|
|
468
|
+
foreach (T element in stack)
|
|
469
|
+
{
|
|
470
|
+
if (index == i++)
|
|
471
|
+
{
|
|
472
|
+
return element;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
throw new ArgumentException(nameof(collection));
|
|
477
|
+
}
|
|
478
|
+
default:
|
|
479
|
+
{
|
|
480
|
+
return collection.ElementAt(index);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
413
483
|
}
|
|
414
484
|
|
|
415
485
|
public T NextOf<T>(IReadOnlyList<T> list)
|
package/Runtime/Utils/Buffers.cs
CHANGED
|
@@ -5,6 +5,7 @@ namespace WallstopStudios.UnityHelpers.Utils
|
|
|
5
5
|
using System.Reflection;
|
|
6
6
|
using System.Text;
|
|
7
7
|
using UnityEngine;
|
|
8
|
+
using WallstopStudios.UnityHelpers.Core.Helper;
|
|
8
9
|
|
|
9
10
|
public static class Buffers
|
|
10
11
|
{
|
|
@@ -38,10 +39,16 @@ namespace WallstopStudios.UnityHelpers.Utils
|
|
|
38
39
|
public static class WallstopGenericPool<T>
|
|
39
40
|
where T : new()
|
|
40
41
|
{
|
|
42
|
+
public static Action<T> clearAction;
|
|
43
|
+
|
|
41
44
|
private static readonly List<T> _pool = new();
|
|
42
|
-
private static readonly Action<T> _clearAction = GetClearAction();
|
|
43
45
|
private static readonly Action<T> _onDispose = Release;
|
|
44
46
|
|
|
47
|
+
static WallstopGenericPool()
|
|
48
|
+
{
|
|
49
|
+
clearAction = GetClearAction();
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
public static PooledResource<T> Get()
|
|
46
53
|
{
|
|
47
54
|
if (_pool.Count == 0)
|
|
@@ -57,26 +64,34 @@ namespace WallstopStudios.UnityHelpers.Utils
|
|
|
57
64
|
|
|
58
65
|
private static Action<T> GetClearAction()
|
|
59
66
|
{
|
|
60
|
-
|
|
61
|
-
foreach (
|
|
62
|
-
MethodInfo method in type.GetMethods(BindingFlags.Instance | BindingFlags.Public)
|
|
63
|
-
)
|
|
67
|
+
try
|
|
64
68
|
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
Type type = typeof(T);
|
|
70
|
+
foreach (
|
|
71
|
+
MethodInfo method in type.GetMethods(
|
|
72
|
+
BindingFlags.Instance | BindingFlags.Public
|
|
73
|
+
)
|
|
68
74
|
)
|
|
69
75
|
{
|
|
70
|
-
|
|
76
|
+
if (
|
|
77
|
+
string.Equals(method.Name, "Clear", StringComparison.Ordinal)
|
|
78
|
+
&& method.GetParameters().Length == 0
|
|
79
|
+
)
|
|
80
|
+
{
|
|
81
|
+
return (Action<T>)Delegate.CreateDelegate(typeof(Action<T>), method);
|
|
82
|
+
}
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
catch
|
|
86
|
+
{
|
|
87
|
+
// Swallow
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
75
90
|
}
|
|
76
91
|
|
|
77
92
|
private static void Release(T resource)
|
|
78
93
|
{
|
|
79
|
-
|
|
94
|
+
clearAction?.Invoke(resource);
|
|
80
95
|
_pool.Add(resource);
|
|
81
96
|
}
|
|
82
97
|
}
|
package/package.json
CHANGED