com.wallstop-studios.unity-helpers 2.0.0-rc73.1 → 2.0.0-rc73.11
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 +58 -50
- package/Editor/AnimationCreator.cs +24 -24
- package/Editor/AnimationEventEditor.cs +11 -23
- package/Editor/FitTextureSizeWindow.cs +9 -9
- package/Editor/PrefabChecker.cs +12 -18
- package/Editor/SpriteAtlasGenerator.cs +47 -66
- package/Editor/SpriteCropper.cs +157 -131
- package/Editor/SpriteSettingsApplier.cs +5 -3
- package/Editor/Utils/GUIIndentScope.cs +20 -0
- package/Editor/Utils/GUIIndentScope.cs.meta +3 -0
- package/Runtime/Core/DataStructure/Circle.cs +1 -1
- package/Runtime/Core/DataStructure/QuadTree.cs +4 -4
- package/Runtime/Core/Extension/ColorExtensions.cs +5 -5
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
- package/Runtime/Core/Extension/UnityExtensions.cs +14 -14
- package/Runtime/Core/Helper/Helpers.cs +9 -9
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +31 -8
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +2 -2
- package/Runtime/Core/Helper/PathHelper.cs +15 -0
- package/Runtime/Core/Helper/PathHelper.cs.meta +3 -0
- package/Runtime/Core/Random/DotNetRandom.cs +1 -1
- package/Runtime/Core/Random/SplitMix64.cs +1 -1
- package/Runtime/Core/Random/SquirrelRandom.cs +7 -7
- package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
- package/Runtime/Core/Random/WyRandom.cs +1 -1
- package/Runtime/Tags/AttributeEffect.cs +1 -0
- package/Runtime/Tags/EffectHandler.cs +1 -1
- package/Runtime/UI/LayeredImage.cs +309 -161
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
- package/Runtime/Utils/SetTextureImportData.cs +1 -1
- package/Runtime/Utils/TextureScale.cs +4 -4
- package/Styles/Elements/Progress/ArcedProgressBar.cs +345 -0
- package/Styles/Elements/Progress/ArcedProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress/CircularProgressBar.cs +307 -0
- package/Styles/Elements/Progress/CircularProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress/GlitchProgressBar.cs +416 -0
- package/Styles/Elements/Progress/GlitchProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress/LiquidProgressBar.cs +632 -0
- package/Styles/Elements/Progress/LiquidProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress/MarchingAntsProgressBar.cs +722 -0
- package/Styles/Elements/Progress/MarchingAntsProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress/RegularProgressBar.cs +405 -0
- package/Styles/Elements/Progress/RegularProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress/WigglyProgressBar.cs +837 -0
- package/Styles/Elements/Progress/WigglyProgressBar.cs.meta +3 -0
- package/Styles/Elements/Progress.meta +3 -0
- package/Styles/Elements.meta +3 -0
- package/Styles/USS/ArcedProgressBar.uss +19 -0
- package/Styles/USS/ArcedProgressBar.uss.meta +3 -0
- package/Styles/USS/CirclularProgressBar.uss +18 -0
- package/Styles/USS/CirclularProgressBar.uss.meta +3 -0
- package/Styles/USS/RegularProgressBar.uss +33 -0
- package/Styles/USS/RegularProgressBar.uss.meta +3 -0
- package/Styles/USS/WigglyProgressBar.uss +17 -0
- package/Styles/USS/WigglyProgressBar.uss.meta +3 -0
- package/Styles/USS.meta +3 -0
- package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef +17 -0
- package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef.meta +7 -0
- package/Styles.meta +3 -0
- package/package.json +11 -1
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Styles.Elements.Progress
|
|
2
|
+
{
|
|
3
|
+
using System.ComponentModel;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.UIElements;
|
|
6
|
+
|
|
7
|
+
public sealed class RegularProgressBar : VisualElement
|
|
8
|
+
{
|
|
9
|
+
public const string USSClassName = "regular-progress-bar";
|
|
10
|
+
public const string USSTrackClassName = USSClassName + "__track";
|
|
11
|
+
public const string USSFillClassName = USSClassName + "__fill";
|
|
12
|
+
|
|
13
|
+
public const string USSTrackColorVarName = "--rpb-track-color";
|
|
14
|
+
public const string USSProgressColorVarName = "--rpb-progress-color";
|
|
15
|
+
public const string USSBorderRadiusVarName = "--rpb-border-radius";
|
|
16
|
+
public const string USSThicknessVarName = "--rpb-thickness";
|
|
17
|
+
|
|
18
|
+
private readonly VisualElement _trackElement;
|
|
19
|
+
private readonly VisualElement _fillElement;
|
|
20
|
+
|
|
21
|
+
public enum OrientationType
|
|
22
|
+
{
|
|
23
|
+
Horizontal = 0,
|
|
24
|
+
Vertical = 1,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public enum FillDirection
|
|
28
|
+
{
|
|
29
|
+
Forward = 0,
|
|
30
|
+
Reverse = 1,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private float _progress = 0.5f;
|
|
34
|
+
public float Progress
|
|
35
|
+
{
|
|
36
|
+
get => _progress;
|
|
37
|
+
set
|
|
38
|
+
{
|
|
39
|
+
if (float.IsNaN(value) || float.IsInfinity(value))
|
|
40
|
+
{
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
_progress = Mathf.Clamp01(value);
|
|
44
|
+
UpdateFillVisuals();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private Color _trackColor = new(0.3f, 0.3f, 0.3f, 1f);
|
|
49
|
+
public Color TrackColor
|
|
50
|
+
{
|
|
51
|
+
get => _trackColor;
|
|
52
|
+
set
|
|
53
|
+
{
|
|
54
|
+
_trackColor = value;
|
|
55
|
+
if (_trackElement != null)
|
|
56
|
+
{
|
|
57
|
+
_trackElement.style.backgroundColor = _trackColor;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private Color _progressColor = new(0.2f, 0.7f, 0.2f, 1f);
|
|
63
|
+
public Color ProgressColor
|
|
64
|
+
{
|
|
65
|
+
get => _progressColor;
|
|
66
|
+
set
|
|
67
|
+
{
|
|
68
|
+
_progressColor = value;
|
|
69
|
+
if (_fillElement != null)
|
|
70
|
+
{
|
|
71
|
+
_fillElement.style.backgroundColor = _progressColor;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private OrientationType _orientation = OrientationType.Horizontal;
|
|
77
|
+
public OrientationType Orientation
|
|
78
|
+
{
|
|
79
|
+
get => _orientation;
|
|
80
|
+
set
|
|
81
|
+
{
|
|
82
|
+
_orientation = value;
|
|
83
|
+
UpdateOrientationVisuals();
|
|
84
|
+
UpdateFillVisuals();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private FillDirection _fillDirection = FillDirection.Forward;
|
|
89
|
+
|
|
90
|
+
public FillDirection Direction
|
|
91
|
+
{
|
|
92
|
+
get => _fillDirection;
|
|
93
|
+
set
|
|
94
|
+
{
|
|
95
|
+
_fillDirection = value;
|
|
96
|
+
UpdateOrientationVisuals();
|
|
97
|
+
UpdateFillVisuals();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private float _borderRadius = 3f;
|
|
102
|
+
public float BorderRadius
|
|
103
|
+
{
|
|
104
|
+
get => _borderRadius;
|
|
105
|
+
set
|
|
106
|
+
{
|
|
107
|
+
if (float.IsNaN(value) || float.IsInfinity(value))
|
|
108
|
+
{
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
_borderRadius = Mathf.Max(0, value);
|
|
112
|
+
ApplyBorderRadius();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private float _thickness = 15f;
|
|
117
|
+
public float Thickness
|
|
118
|
+
{
|
|
119
|
+
get => _thickness;
|
|
120
|
+
set
|
|
121
|
+
{
|
|
122
|
+
if (float.IsNaN(value) || float.IsInfinity(value))
|
|
123
|
+
{
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
_thickness = Mathf.Max(1, value);
|
|
127
|
+
UpdateThicknessVisuals();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public new class UxmlFactory : UxmlFactory<RegularProgressBar, UxmlTraits> { }
|
|
132
|
+
|
|
133
|
+
public new class UxmlTraits : VisualElement.UxmlTraits
|
|
134
|
+
{
|
|
135
|
+
private readonly UxmlFloatAttributeDescription _progressAttribute = new()
|
|
136
|
+
{
|
|
137
|
+
name = "progress",
|
|
138
|
+
defaultValue = 0.5f,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
private readonly UxmlColorAttributeDescription _trackColorAttribute = new()
|
|
142
|
+
{
|
|
143
|
+
name = "track-color-attr",
|
|
144
|
+
defaultValue = new Color(0.3f, 0.3f, 0.3f, 1f),
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
private readonly UxmlColorAttributeDescription _progressColorAttribute = new()
|
|
148
|
+
{
|
|
149
|
+
name = "progress-color-attr",
|
|
150
|
+
defaultValue = new Color(0.2f, 0.7f, 0.2f, 1f),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
private readonly UxmlEnumAttributeDescription<OrientationType> _orientationAttribute =
|
|
154
|
+
new() { name = "orientation", defaultValue = OrientationType.Horizontal };
|
|
155
|
+
|
|
156
|
+
private readonly UxmlEnumAttributeDescription<FillDirection> _fillAttribute = new()
|
|
157
|
+
{
|
|
158
|
+
name = "direction",
|
|
159
|
+
defaultValue = FillDirection.Forward,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
private readonly UxmlFloatAttributeDescription _borderRadiusAttribute = new()
|
|
163
|
+
{
|
|
164
|
+
name = "border-radius",
|
|
165
|
+
defaultValue = 3f,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
private readonly UxmlFloatAttributeDescription _thicknessAttribute = new()
|
|
169
|
+
{
|
|
170
|
+
name = "thickness",
|
|
171
|
+
defaultValue = 15f,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
|
|
175
|
+
{
|
|
176
|
+
base.Init(ve, bag, cc);
|
|
177
|
+
if (ve is not RegularProgressBar bar)
|
|
178
|
+
{
|
|
179
|
+
Debug.LogError(
|
|
180
|
+
$"Initialization failed, expected {nameof(RegularProgressBar)}, found {ve?.GetType()}.)"
|
|
181
|
+
);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
bar.Progress = _progressAttribute.GetValueFromBag(bag, cc);
|
|
186
|
+
bar.TrackColor = _trackColorAttribute.GetValueFromBag(bag, cc);
|
|
187
|
+
bar.ProgressColor = _progressColorAttribute.GetValueFromBag(bag, cc);
|
|
188
|
+
bar.Thickness = _thicknessAttribute.GetValueFromBag(bag, cc);
|
|
189
|
+
bar.Orientation = _orientationAttribute.GetValueFromBag(bag, cc);
|
|
190
|
+
bar.BorderRadius = _borderRadiusAttribute.GetValueFromBag(bag, cc);
|
|
191
|
+
bar.Direction = _fillAttribute.GetValueFromBag(bag, cc);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public RegularProgressBar()
|
|
196
|
+
{
|
|
197
|
+
AddToClassList(USSClassName);
|
|
198
|
+
|
|
199
|
+
_trackElement = new VisualElement { name = "track" };
|
|
200
|
+
_trackElement.AddToClassList(USSTrackClassName);
|
|
201
|
+
Add(_trackElement);
|
|
202
|
+
|
|
203
|
+
_fillElement = new VisualElement { name = "fill" };
|
|
204
|
+
_fillElement.AddToClassList(USSFillClassName);
|
|
205
|
+
_trackElement.Add(_fillElement);
|
|
206
|
+
|
|
207
|
+
_trackElement.style.width = Length.Percent(100);
|
|
208
|
+
_trackElement.style.height = Length.Percent(100);
|
|
209
|
+
_trackElement.style.overflow = Overflow.Hidden;
|
|
210
|
+
|
|
211
|
+
_fillElement.style.position = Position.Absolute;
|
|
212
|
+
|
|
213
|
+
TrackColor = _trackColor;
|
|
214
|
+
ProgressColor = _progressColor;
|
|
215
|
+
Thickness = _thickness;
|
|
216
|
+
Orientation = _orientation;
|
|
217
|
+
BorderRadius = _borderRadius;
|
|
218
|
+
|
|
219
|
+
RegisterCallback<CustomStyleResolvedEvent>(OnCustomStyleResolved);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private void OnCustomStyleResolved(CustomStyleResolvedEvent evt)
|
|
223
|
+
{
|
|
224
|
+
if (
|
|
225
|
+
customStyle.TryGetValue(
|
|
226
|
+
new CustomStyleProperty<Color>(USSTrackColorVarName),
|
|
227
|
+
out Color trackCol
|
|
228
|
+
)
|
|
229
|
+
)
|
|
230
|
+
{
|
|
231
|
+
TrackColor = trackCol;
|
|
232
|
+
}
|
|
233
|
+
if (
|
|
234
|
+
customStyle.TryGetValue(
|
|
235
|
+
new CustomStyleProperty<Color>(USSProgressColorVarName),
|
|
236
|
+
out Color progressCol
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
{
|
|
240
|
+
ProgressColor = progressCol;
|
|
241
|
+
}
|
|
242
|
+
if (
|
|
243
|
+
customStyle.TryGetValue(
|
|
244
|
+
new CustomStyleProperty<float>(USSBorderRadiusVarName),
|
|
245
|
+
out float radius
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
{
|
|
249
|
+
BorderRadius = radius;
|
|
250
|
+
}
|
|
251
|
+
if (
|
|
252
|
+
customStyle.TryGetValue(
|
|
253
|
+
new CustomStyleProperty<float>(USSThicknessVarName),
|
|
254
|
+
out float thicknessVal
|
|
255
|
+
)
|
|
256
|
+
)
|
|
257
|
+
{
|
|
258
|
+
Thickness = thicknessVal;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private void UpdateThicknessVisuals()
|
|
263
|
+
{
|
|
264
|
+
style.height = _thickness;
|
|
265
|
+
style.minHeight = _thickness;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private void UpdateOrientationVisuals()
|
|
269
|
+
{
|
|
270
|
+
UpdateThicknessVisuals();
|
|
271
|
+
|
|
272
|
+
switch (_orientation)
|
|
273
|
+
{
|
|
274
|
+
case OrientationType.Horizontal:
|
|
275
|
+
{
|
|
276
|
+
switch (_fillDirection)
|
|
277
|
+
{
|
|
278
|
+
case FillDirection.Forward:
|
|
279
|
+
{
|
|
280
|
+
_fillElement.style.right = StyleKeyword.Auto;
|
|
281
|
+
_fillElement.style.left = 0;
|
|
282
|
+
_fillElement.style.top = 0;
|
|
283
|
+
_fillElement.style.bottom = 0;
|
|
284
|
+
_fillElement.style.height = Length.Percent(100);
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case FillDirection.Reverse:
|
|
288
|
+
{
|
|
289
|
+
_fillElement.style.left = StyleKeyword.Auto;
|
|
290
|
+
_fillElement.style.top = 0;
|
|
291
|
+
_fillElement.style.bottom = 0;
|
|
292
|
+
_fillElement.style.right = 0;
|
|
293
|
+
_fillElement.style.height = Length.Percent(100);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
default:
|
|
297
|
+
{
|
|
298
|
+
throw new InvalidEnumArgumentException(
|
|
299
|
+
nameof(_fillDirection),
|
|
300
|
+
(int)_fillDirection,
|
|
301
|
+
typeof(FillDirection)
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case OrientationType.Vertical:
|
|
309
|
+
{
|
|
310
|
+
switch (_fillDirection)
|
|
311
|
+
{
|
|
312
|
+
case FillDirection.Forward:
|
|
313
|
+
{
|
|
314
|
+
_fillElement.style.left = 0;
|
|
315
|
+
_fillElement.style.top = StyleKeyword.Auto;
|
|
316
|
+
_fillElement.style.bottom = 0;
|
|
317
|
+
_fillElement.style.right = 0;
|
|
318
|
+
_fillElement.style.width = Length.Percent(100);
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
case FillDirection.Reverse:
|
|
322
|
+
{
|
|
323
|
+
_fillElement.style.left = 0;
|
|
324
|
+
_fillElement.style.top = 0;
|
|
325
|
+
_fillElement.style.bottom = StyleKeyword.Auto;
|
|
326
|
+
_fillElement.style.right = 0;
|
|
327
|
+
_fillElement.style.width = Length.Percent(100);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
default:
|
|
331
|
+
{
|
|
332
|
+
throw new InvalidEnumArgumentException(
|
|
333
|
+
nameof(_fillDirection),
|
|
334
|
+
(int)_fillDirection,
|
|
335
|
+
typeof(FillDirection)
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
default:
|
|
343
|
+
{
|
|
344
|
+
throw new InvalidEnumArgumentException(
|
|
345
|
+
nameof(_orientation),
|
|
346
|
+
(int)_orientation,
|
|
347
|
+
typeof(OrientationType)
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private void ApplyBorderRadius()
|
|
354
|
+
{
|
|
355
|
+
if (_trackElement != null)
|
|
356
|
+
{
|
|
357
|
+
_trackElement.style.borderTopLeftRadius = _borderRadius;
|
|
358
|
+
_trackElement.style.borderTopRightRadius = _borderRadius;
|
|
359
|
+
_trackElement.style.borderBottomLeftRadius = _borderRadius;
|
|
360
|
+
_trackElement.style.borderBottomRightRadius = _borderRadius;
|
|
361
|
+
}
|
|
362
|
+
if (_fillElement != null)
|
|
363
|
+
{
|
|
364
|
+
_fillElement.style.borderTopLeftRadius = _borderRadius;
|
|
365
|
+
_fillElement.style.borderTopRightRadius = _borderRadius;
|
|
366
|
+
_fillElement.style.borderBottomLeftRadius = _borderRadius;
|
|
367
|
+
_fillElement.style.borderBottomRightRadius = _borderRadius;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
private void UpdateFillVisuals()
|
|
372
|
+
{
|
|
373
|
+
if (_fillElement == null)
|
|
374
|
+
{
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
float clampedProgress = Mathf.Clamp01(_progress);
|
|
379
|
+
|
|
380
|
+
switch (_orientation)
|
|
381
|
+
{
|
|
382
|
+
case OrientationType.Horizontal:
|
|
383
|
+
{
|
|
384
|
+
_fillElement.style.width = Length.Percent(clampedProgress * 100f);
|
|
385
|
+
_fillElement.style.height = Length.Percent(100);
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
case OrientationType.Vertical:
|
|
389
|
+
{
|
|
390
|
+
_fillElement.style.height = Length.Percent(clampedProgress * 100f);
|
|
391
|
+
_fillElement.style.width = Length.Percent(100);
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
default:
|
|
395
|
+
{
|
|
396
|
+
throw new InvalidEnumArgumentException(
|
|
397
|
+
nameof(_orientation),
|
|
398
|
+
(int)_orientation,
|
|
399
|
+
typeof(OrientationType)
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|