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.
Files changed (60) hide show
  1. package/Editor/AnimationCopier.cs +58 -50
  2. package/Editor/AnimationCreator.cs +24 -24
  3. package/Editor/AnimationEventEditor.cs +11 -23
  4. package/Editor/FitTextureSizeWindow.cs +9 -9
  5. package/Editor/PrefabChecker.cs +12 -18
  6. package/Editor/SpriteAtlasGenerator.cs +47 -66
  7. package/Editor/SpriteCropper.cs +157 -131
  8. package/Editor/SpriteSettingsApplier.cs +5 -3
  9. package/Editor/Utils/GUIIndentScope.cs +20 -0
  10. package/Editor/Utils/GUIIndentScope.cs.meta +3 -0
  11. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  12. package/Runtime/Core/DataStructure/QuadTree.cs +4 -4
  13. package/Runtime/Core/Extension/ColorExtensions.cs +5 -5
  14. package/Runtime/Core/Extension/IEnumerableExtensions.cs +1 -1
  15. package/Runtime/Core/Extension/UnityExtensions.cs +14 -14
  16. package/Runtime/Core/Helper/Helpers.cs +9 -9
  17. package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +31 -8
  18. package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +2 -2
  19. package/Runtime/Core/Helper/PathHelper.cs +15 -0
  20. package/Runtime/Core/Helper/PathHelper.cs.meta +3 -0
  21. package/Runtime/Core/Random/DotNetRandom.cs +1 -1
  22. package/Runtime/Core/Random/SplitMix64.cs +1 -1
  23. package/Runtime/Core/Random/SquirrelRandom.cs +7 -7
  24. package/Runtime/Core/Random/ThreadLocalRandom.cs +1 -1
  25. package/Runtime/Core/Random/WyRandom.cs +1 -1
  26. package/Runtime/Tags/AttributeEffect.cs +1 -0
  27. package/Runtime/Tags/EffectHandler.cs +1 -1
  28. package/Runtime/UI/LayeredImage.cs +309 -161
  29. package/Runtime/Utils/AnimatorEnumStateMachine.cs +1 -1
  30. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  31. package/Runtime/Utils/TextureScale.cs +4 -4
  32. package/Styles/Elements/Progress/ArcedProgressBar.cs +345 -0
  33. package/Styles/Elements/Progress/ArcedProgressBar.cs.meta +3 -0
  34. package/Styles/Elements/Progress/CircularProgressBar.cs +307 -0
  35. package/Styles/Elements/Progress/CircularProgressBar.cs.meta +3 -0
  36. package/Styles/Elements/Progress/GlitchProgressBar.cs +416 -0
  37. package/Styles/Elements/Progress/GlitchProgressBar.cs.meta +3 -0
  38. package/Styles/Elements/Progress/LiquidProgressBar.cs +632 -0
  39. package/Styles/Elements/Progress/LiquidProgressBar.cs.meta +3 -0
  40. package/Styles/Elements/Progress/MarchingAntsProgressBar.cs +722 -0
  41. package/Styles/Elements/Progress/MarchingAntsProgressBar.cs.meta +3 -0
  42. package/Styles/Elements/Progress/RegularProgressBar.cs +405 -0
  43. package/Styles/Elements/Progress/RegularProgressBar.cs.meta +3 -0
  44. package/Styles/Elements/Progress/WigglyProgressBar.cs +837 -0
  45. package/Styles/Elements/Progress/WigglyProgressBar.cs.meta +3 -0
  46. package/Styles/Elements/Progress.meta +3 -0
  47. package/Styles/Elements.meta +3 -0
  48. package/Styles/USS/ArcedProgressBar.uss +19 -0
  49. package/Styles/USS/ArcedProgressBar.uss.meta +3 -0
  50. package/Styles/USS/CirclularProgressBar.uss +18 -0
  51. package/Styles/USS/CirclularProgressBar.uss.meta +3 -0
  52. package/Styles/USS/RegularProgressBar.uss +33 -0
  53. package/Styles/USS/RegularProgressBar.uss.meta +3 -0
  54. package/Styles/USS/WigglyProgressBar.uss +17 -0
  55. package/Styles/USS/WigglyProgressBar.uss.meta +3 -0
  56. package/Styles/USS.meta +3 -0
  57. package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef +17 -0
  58. package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef.meta +7 -0
  59. package/Styles.meta +3 -0
  60. package/package.json +11 -1
@@ -54,8 +54,8 @@
54
54
  }
55
55
  else
56
56
  {
57
- ratioX = ((float)tex.width) / newWidth;
58
- ratioY = ((float)tex.height) / newHeight;
57
+ ratioX = (float)tex.width / newWidth;
58
+ ratioY = (float)tex.height / newHeight;
59
59
  }
60
60
 
61
61
  w = tex.width;
@@ -123,7 +123,7 @@
123
123
  int y2 = (yFloor + 1) * w;
124
124
  int yw = y * w2;
125
125
 
126
- for (var x = 0; x < w2; x++)
126
+ for (int x = 0; x < w2; x++)
127
127
  {
128
128
  int xFloor = (int)Mathf.Floor(x * ratioX);
129
129
  float xLerp = x * ratioX - xFloor;
@@ -155,7 +155,7 @@
155
155
  {
156
156
  int thisY = (int)(ratioY * y) * w;
157
157
  int yw = y * w2;
158
- for (var x = 0; x < w2; x++)
158
+ for (int x = 0; x < w2; x++)
159
159
  {
160
160
  newColors[yw + x] = texColors[(int)(thisY + ratioX * x)];
161
161
  }
@@ -0,0 +1,345 @@
1
+ namespace WallstopStudios.UnityHelpers.Styles.Elements.Progress
2
+ {
3
+ using System.ComponentModel;
4
+ using Core.Helper;
5
+ using UnityEngine;
6
+ using UnityEngine.UIElements;
7
+
8
+ public sealed class ArcedProgressBar : VisualElement
9
+ {
10
+ public enum FillDirection
11
+ {
12
+ Forward = 0,
13
+ Reverse = 1,
14
+ }
15
+
16
+ public const string USSClassName = "arced-progress-bar";
17
+ public const string USSTrackColorVarName = "--arc-track-color";
18
+ public const string USSProgressColorVarName = "--arc-progress-color";
19
+ public const string USSThicknessVarName = "--arc-thickness";
20
+
21
+ private float _progress = 0.5f;
22
+
23
+ public float Progress
24
+ {
25
+ get => _progress;
26
+ set
27
+ {
28
+ if (float.IsNaN(value) || float.IsInfinity(value))
29
+ {
30
+ return;
31
+ }
32
+ _progress = Mathf.Clamp01(value);
33
+ MarkDirtyRepaint();
34
+ }
35
+ }
36
+
37
+ private float _radius = 50f;
38
+
39
+ public float Radius
40
+ {
41
+ get => _radius;
42
+ set
43
+ {
44
+ if (float.IsNaN(value) || float.IsInfinity(value))
45
+ {
46
+ return;
47
+ }
48
+ _radius = Mathf.Max(1f, value);
49
+ UpdateSize();
50
+ MarkDirtyRepaint();
51
+ }
52
+ }
53
+
54
+ private float _thickness = 10f;
55
+
56
+ public float Thickness
57
+ {
58
+ get => _thickness;
59
+ set
60
+ {
61
+ if (float.IsNaN(value) || float.IsInfinity(value))
62
+ {
63
+ return;
64
+ }
65
+ _thickness = Mathf.Max(1f, value);
66
+ UpdateSize();
67
+ MarkDirtyRepaint();
68
+ }
69
+ }
70
+
71
+ private float _startAngleDegrees = -90f;
72
+
73
+ public float StartAngleDegrees
74
+ {
75
+ get => _startAngleDegrees;
76
+ set
77
+ {
78
+ if (float.IsNaN(value) || float.IsInfinity(value))
79
+ {
80
+ return;
81
+ }
82
+ _startAngleDegrees = value;
83
+ MarkDirtyRepaint();
84
+ }
85
+ }
86
+
87
+ private float _endAngleDegrees = 90f;
88
+
89
+ public float EndAngleDegrees
90
+ {
91
+ get => _endAngleDegrees;
92
+ set
93
+ {
94
+ if (float.IsNaN(value) || float.IsInfinity(value))
95
+ {
96
+ return;
97
+ }
98
+ _endAngleDegrees = value;
99
+ MarkDirtyRepaint();
100
+ }
101
+ }
102
+
103
+ private FillDirection _fillDirection = FillDirection.Forward;
104
+
105
+ public FillDirection Direction
106
+ {
107
+ get => _fillDirection;
108
+ set
109
+ {
110
+ _fillDirection = value;
111
+ MarkDirtyRepaint();
112
+ }
113
+ }
114
+
115
+ private bool _roundedCaps = true;
116
+
117
+ public bool RoundedCaps
118
+ {
119
+ get => _roundedCaps;
120
+ set
121
+ {
122
+ _roundedCaps = value;
123
+ MarkDirtyRepaint();
124
+ }
125
+ }
126
+
127
+ private Color _trackColor = Color.gray;
128
+
129
+ public Color TrackColor
130
+ {
131
+ get => _trackColor;
132
+ set
133
+ {
134
+ _trackColor = value;
135
+ MarkDirtyRepaint();
136
+ }
137
+ }
138
+
139
+ private Color _progressColor = Color.cyan;
140
+
141
+ public Color ProgressColor
142
+ {
143
+ get => _progressColor;
144
+ set
145
+ {
146
+ _progressColor = value;
147
+ MarkDirtyRepaint();
148
+ }
149
+ }
150
+
151
+ public new class UxmlFactory : UxmlFactory<ArcedProgressBar, UxmlTraits> { }
152
+
153
+ public new class UxmlTraits : VisualElement.UxmlTraits
154
+ {
155
+ private readonly UxmlFloatAttributeDescription _progressAttribute = new()
156
+ {
157
+ name = "progress",
158
+ defaultValue = 0.5f,
159
+ };
160
+
161
+ private readonly UxmlFloatAttributeDescription _radiusAttribute = new()
162
+ {
163
+ name = "radius",
164
+ defaultValue = 50f,
165
+ };
166
+
167
+ private readonly UxmlFloatAttributeDescription _thicknessAttribute = new()
168
+ {
169
+ name = "thickness",
170
+ defaultValue = 10f,
171
+ };
172
+
173
+ private readonly UxmlFloatAttributeDescription _startAngleAttribute = new()
174
+ {
175
+ name = "start-angle",
176
+ defaultValue = -90f,
177
+ };
178
+
179
+ private readonly UxmlFloatAttributeDescription _endAngleAttribute = new()
180
+ {
181
+ name = "end-angle",
182
+ defaultValue = 90f,
183
+ };
184
+
185
+ private readonly UxmlEnumAttributeDescription<FillDirection> _fillDirectionAttribute =
186
+ new() { name = "fill-direction", defaultValue = FillDirection.Forward };
187
+
188
+ private readonly UxmlBoolAttributeDescription _roundedCapsAttribute = new()
189
+ {
190
+ name = "rounded-caps",
191
+ defaultValue = true,
192
+ };
193
+
194
+ private readonly UxmlColorAttributeDescription _trackColorAttribute = new()
195
+ {
196
+ name = "track-color-attr",
197
+ defaultValue = Color.gray,
198
+ };
199
+
200
+ private readonly UxmlColorAttributeDescription _progressColorAttribute = new()
201
+ {
202
+ name = "progress-color-attr",
203
+ defaultValue = Color.cyan,
204
+ };
205
+
206
+ public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
207
+ {
208
+ base.Init(ve, bag, cc);
209
+ if (ve is not ArcedProgressBar bar)
210
+ {
211
+ Debug.LogError(
212
+ $"Initialization failed, expected {nameof(ArcedProgressBar)}, found {ve?.GetType()}.)"
213
+ );
214
+ return;
215
+ }
216
+
217
+ bar.Progress = _progressAttribute.GetValueFromBag(bag, cc);
218
+ bar.Radius = _radiusAttribute.GetValueFromBag(bag, cc);
219
+ bar.Thickness = _thicknessAttribute.GetValueFromBag(bag, cc);
220
+ bar.StartAngleDegrees = _startAngleAttribute.GetValueFromBag(bag, cc);
221
+ bar.EndAngleDegrees = _endAngleAttribute.GetValueFromBag(bag, cc);
222
+ bar.Direction = _fillDirectionAttribute.GetValueFromBag(bag, cc);
223
+ bar.RoundedCaps = _roundedCapsAttribute.GetValueFromBag(bag, cc);
224
+ bar.TrackColor = _trackColorAttribute.GetValueFromBag(bag, cc);
225
+ bar.ProgressColor = _progressColorAttribute.GetValueFromBag(bag, cc);
226
+ }
227
+ }
228
+
229
+ public ArcedProgressBar()
230
+ {
231
+ AddToClassList(USSClassName);
232
+ generateVisualContent += OnGenerateVisualContent;
233
+ RegisterCallback<CustomStyleResolvedEvent>(OnCustomStyleResolved);
234
+ UpdateSize();
235
+ }
236
+
237
+ private void UpdateSize()
238
+ {
239
+ float diameter = (_radius + _thickness / 2f) * 2f;
240
+ style.width = diameter;
241
+ style.height = diameter;
242
+ style.minWidth = diameter;
243
+ style.minHeight = diameter;
244
+ }
245
+
246
+ private void OnCustomStyleResolved(CustomStyleResolvedEvent evt)
247
+ {
248
+ if (
249
+ customStyle.TryGetValue(
250
+ new CustomStyleProperty<Color>(USSTrackColorVarName),
251
+ out Color trackCol
252
+ )
253
+ )
254
+ {
255
+ _trackColor = trackCol;
256
+ }
257
+
258
+ if (
259
+ customStyle.TryGetValue(
260
+ new CustomStyleProperty<Color>(USSProgressColorVarName),
261
+ out Color progressCol
262
+ )
263
+ )
264
+ {
265
+ _progressColor = progressCol;
266
+ }
267
+
268
+ if (
269
+ customStyle.TryGetValue(
270
+ new CustomStyleProperty<float>(USSThicknessVarName),
271
+ out float thickVal
272
+ )
273
+ )
274
+ {
275
+ _thickness = Mathf.Max(1f, thickVal);
276
+ }
277
+
278
+ MarkDirtyRepaint();
279
+ }
280
+
281
+ private void OnGenerateVisualContent(MeshGenerationContext mgc)
282
+ {
283
+ if (_thickness <= 0)
284
+ {
285
+ return;
286
+ }
287
+
288
+ Painter2D painter = mgc.painter2D;
289
+ Rect rect = contentRect;
290
+ Vector2 center = rect.center;
291
+
292
+ painter.lineWidth = _thickness;
293
+ painter.lineCap = _roundedCaps ? LineCap.Round : LineCap.Butt;
294
+
295
+ painter.strokeColor = _trackColor;
296
+ painter.BeginPath();
297
+ painter.Arc(center, _radius, _startAngleDegrees, _endAngleDegrees);
298
+ painter.Stroke();
299
+
300
+ if (Mathf.Approximately(_progress, 0f))
301
+ {
302
+ return;
303
+ }
304
+
305
+ float startAngle;
306
+ ArcDirection direction;
307
+ float sweepAngleDegrees;
308
+ switch (_fillDirection)
309
+ {
310
+ case FillDirection.Forward:
311
+ {
312
+ startAngle = _startAngleDegrees;
313
+ direction = ArcDirection.Clockwise;
314
+ sweepAngleDegrees =
315
+ _progress * (_endAngleDegrees - _startAngleDegrees).PositiveMod(360f);
316
+ break;
317
+ }
318
+ case FillDirection.Reverse:
319
+ {
320
+ startAngle = _endAngleDegrees;
321
+ direction = ArcDirection.CounterClockwise;
322
+ sweepAngleDegrees =
323
+ -1 * _progress * (_endAngleDegrees - _startAngleDegrees).PositiveMod(360f);
324
+ break;
325
+ }
326
+ default:
327
+ {
328
+ throw new InvalidEnumArgumentException(
329
+ nameof(_fillDirection),
330
+ (int)_fillDirection,
331
+ typeof(FillDirection)
332
+ );
333
+ }
334
+ }
335
+
336
+ if (!Mathf.Approximately(sweepAngleDegrees, 0))
337
+ {
338
+ painter.strokeColor = _progressColor;
339
+ painter.BeginPath();
340
+ painter.Arc(center, _radius, startAngle, startAngle + sweepAngleDegrees, direction);
341
+ painter.Stroke();
342
+ }
343
+ }
344
+ }
345
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 113bae024ddc4a39ab3d77e2f34af18a
3
+ timeCreated: 1746719146
@@ -0,0 +1,307 @@
1
+ namespace WallstopStudios.UnityHelpers.Styles.Elements.Progress
2
+ {
3
+ using System.ComponentModel;
4
+ using UnityEngine;
5
+ using UnityEngine.UIElements;
6
+
7
+ public sealed class CircularProgressBar : VisualElement
8
+ {
9
+ public enum StartPointLocation
10
+ {
11
+ Top = 0,
12
+ Right = 1,
13
+ Bottom = 2,
14
+ Left = 3,
15
+ }
16
+
17
+ public enum FillDirection
18
+ {
19
+ Clockwise = 0,
20
+ CounterClockwise = 1,
21
+ }
22
+
23
+ public const string USSClassName = "circular-progress-bar";
24
+ public const string USSTrackColorVarName = "--track-color";
25
+ public const string USSProgressColorVarName = "--progress-color";
26
+ public const string USSThicknessVarName = "--thickness";
27
+
28
+ private float _progress = 0.5f;
29
+ public float Progress
30
+ {
31
+ get => _progress;
32
+ set
33
+ {
34
+ if (float.IsNaN(value) || float.IsInfinity(value))
35
+ {
36
+ return;
37
+ }
38
+ _progress = Mathf.Clamp01(value);
39
+ MarkDirtyRepaint();
40
+ }
41
+ }
42
+
43
+ private float _radius = 50f;
44
+ public float Radius
45
+ {
46
+ get => _radius;
47
+ set
48
+ {
49
+ if (float.IsNaN(value) || float.IsInfinity(value))
50
+ {
51
+ return;
52
+ }
53
+ _radius = Mathf.Max(1f, value);
54
+ UpdateSize();
55
+ MarkDirtyRepaint();
56
+ }
57
+ }
58
+
59
+ private float _thickness = 10f;
60
+ public float Thickness
61
+ {
62
+ get => _thickness;
63
+ set
64
+ {
65
+ if (float.IsNaN(value) || float.IsInfinity(value))
66
+ {
67
+ return;
68
+ }
69
+ _thickness = Mathf.Max(1f, value);
70
+ UpdateSize();
71
+ MarkDirtyRepaint();
72
+ }
73
+ }
74
+
75
+ private float _startPoint = GetStartAngleInDegrees(StartPointLocation.Top);
76
+ public float StartAt
77
+ {
78
+ get => _startPoint;
79
+ set
80
+ {
81
+ if (float.IsNaN(value) || float.IsInfinity(value))
82
+ {
83
+ return;
84
+ }
85
+ _startPoint = value % 360f;
86
+ MarkDirtyRepaint();
87
+ }
88
+ }
89
+
90
+ private FillDirection _fillDirection = FillDirection.Clockwise;
91
+ public FillDirection Direction
92
+ {
93
+ get => _fillDirection;
94
+ set
95
+ {
96
+ _fillDirection = value;
97
+ MarkDirtyRepaint();
98
+ }
99
+ }
100
+
101
+ private Color _trackColor = Color.gray;
102
+ public Color TrackColor
103
+ {
104
+ get => _trackColor;
105
+ set
106
+ {
107
+ _trackColor = value;
108
+ MarkDirtyRepaint();
109
+ }
110
+ }
111
+
112
+ private Color _progressColor = Color.green;
113
+ public Color ProgressColor
114
+ {
115
+ get => _progressColor;
116
+ set
117
+ {
118
+ _progressColor = value;
119
+ MarkDirtyRepaint();
120
+ }
121
+ }
122
+
123
+ public new class UxmlFactory : UxmlFactory<CircularProgressBar, UxmlTraits> { }
124
+
125
+ public new class UxmlTraits : VisualElement.UxmlTraits
126
+ {
127
+ private readonly UxmlFloatAttributeDescription _progressAttribute = new()
128
+ {
129
+ name = "progress",
130
+ defaultValue = 0.5f,
131
+ };
132
+
133
+ private readonly UxmlFloatAttributeDescription _radiusAttribute = new()
134
+ {
135
+ name = "radius",
136
+ defaultValue = 50f,
137
+ };
138
+
139
+ private readonly UxmlFloatAttributeDescription _thicknessAttribute = new()
140
+ {
141
+ name = "thickness",
142
+ defaultValue = 10f,
143
+ };
144
+
145
+ private readonly UxmlFloatAttributeDescription _startPointAttribute = new()
146
+ {
147
+ name = "start-at",
148
+ defaultValue = GetStartAngleInDegrees(StartPointLocation.Top),
149
+ };
150
+
151
+ private readonly UxmlEnumAttributeDescription<FillDirection> _fillDirectionAttribute =
152
+ new() { name = "direction", defaultValue = FillDirection.Clockwise };
153
+
154
+ private readonly UxmlColorAttributeDescription _trackColorAttribute = new()
155
+ {
156
+ name = "track-color-attr",
157
+ defaultValue = Color.gray,
158
+ };
159
+
160
+ private readonly UxmlColorAttributeDescription _progressColorAttribute = new()
161
+ {
162
+ name = "progress-color-attr",
163
+ defaultValue = Color.green,
164
+ };
165
+
166
+ public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
167
+ {
168
+ base.Init(ve, bag, cc);
169
+ if (ve is not CircularProgressBar bar)
170
+ {
171
+ Debug.LogError(
172
+ $"Initialization failed, expected {nameof(CircularProgressBar)}, found {ve?.GetType()}.)"
173
+ );
174
+ return;
175
+ }
176
+
177
+ bar.Progress = _progressAttribute.GetValueFromBag(bag, cc);
178
+ bar.Radius = _radiusAttribute.GetValueFromBag(bag, cc);
179
+ bar.Thickness = _thicknessAttribute.GetValueFromBag(bag, cc);
180
+ bar.StartAt = _startPointAttribute.GetValueFromBag(bag, cc);
181
+ bar.Direction = _fillDirectionAttribute.GetValueFromBag(bag, cc);
182
+ bar.TrackColor = _trackColorAttribute.GetValueFromBag(bag, cc);
183
+ bar.ProgressColor = _progressColorAttribute.GetValueFromBag(bag, cc);
184
+ }
185
+ }
186
+
187
+ public CircularProgressBar()
188
+ {
189
+ AddToClassList(USSClassName);
190
+ generateVisualContent += OnGenerateVisualContent;
191
+ RegisterCallback<CustomStyleResolvedEvent>(OnCustomStyleResolved);
192
+ UpdateSize();
193
+ }
194
+
195
+ private void UpdateSize()
196
+ {
197
+ float diameter = (_radius + _thickness / 2f) * 2f;
198
+ style.width = diameter;
199
+ style.height = diameter;
200
+ style.minWidth = diameter;
201
+ style.minHeight = diameter;
202
+ }
203
+
204
+ private void OnCustomStyleResolved(CustomStyleResolvedEvent evt)
205
+ {
206
+ if (
207
+ customStyle.TryGetValue(
208
+ new CustomStyleProperty<Color>(USSTrackColorVarName),
209
+ out Color trackCol
210
+ )
211
+ )
212
+ {
213
+ _trackColor = trackCol;
214
+ }
215
+ if (
216
+ customStyle.TryGetValue(
217
+ new CustomStyleProperty<Color>(USSProgressColorVarName),
218
+ out Color progressCol
219
+ )
220
+ )
221
+ {
222
+ _progressColor = progressCol;
223
+ }
224
+ if (
225
+ customStyle.TryGetValue(
226
+ new CustomStyleProperty<float>(USSThicknessVarName),
227
+ out float thickVal
228
+ )
229
+ )
230
+ {
231
+ _thickness = Mathf.Max(1f, thickVal);
232
+ }
233
+ MarkDirtyRepaint();
234
+ }
235
+
236
+ private void OnGenerateVisualContent(MeshGenerationContext mgc)
237
+ {
238
+ Painter2D painter = mgc.painter2D;
239
+ Rect rect = contentRect;
240
+
241
+ float drawRadius = _radius;
242
+ Vector2 center = rect.center;
243
+
244
+ painter.strokeColor = _trackColor;
245
+ painter.lineWidth = _thickness;
246
+ painter.BeginPath();
247
+ painter.Arc(center, drawRadius, 0f, 360f);
248
+ painter.Stroke();
249
+
250
+ if (Mathf.Approximately(_progress, 0))
251
+ {
252
+ return;
253
+ }
254
+
255
+ ArcDirection direction;
256
+ float sweepAngleDegrees;
257
+
258
+ switch (_fillDirection)
259
+ {
260
+ case FillDirection.Clockwise:
261
+ {
262
+ direction = ArcDirection.Clockwise;
263
+ sweepAngleDegrees = _progress * 360f;
264
+ break;
265
+ }
266
+ case FillDirection.CounterClockwise:
267
+ {
268
+ direction = ArcDirection.CounterClockwise;
269
+ sweepAngleDegrees = -1 * _progress * 360f;
270
+ break;
271
+ }
272
+ default:
273
+ {
274
+ throw new InvalidEnumArgumentException(
275
+ nameof(_fillDirection),
276
+ (int)_fillDirection,
277
+ typeof(FillDirection)
278
+ );
279
+ }
280
+ }
281
+
282
+ painter.strokeColor = _progressColor;
283
+ painter.lineWidth = _thickness;
284
+ painter.BeginPath();
285
+ painter.Arc(
286
+ center,
287
+ drawRadius,
288
+ _startPoint,
289
+ _startPoint + sweepAngleDegrees,
290
+ direction
291
+ );
292
+ painter.Stroke();
293
+ }
294
+
295
+ public static float GetStartAngleInDegrees(StartPointLocation location)
296
+ {
297
+ return location switch
298
+ {
299
+ StartPointLocation.Top => -90f,
300
+ StartPointLocation.Right => 0f,
301
+ StartPointLocation.Bottom => 90f,
302
+ StartPointLocation.Left => 180f,
303
+ _ => 90f,
304
+ };
305
+ }
306
+ }
307
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: bb95a7dc54294c45a4a8a41a630ea7cf
3
+ timeCreated: 1746658631