Skip to content

Commit b38dd2f

Browse files
committed
Move settings from Tweening class to new Settings class
1 parent 51e8562 commit b38dd2f

File tree

7 files changed

+94
-74
lines changed

7 files changed

+94
-74
lines changed

Runtime/EaseFunction.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public static float CircInOut(float x)
281281
/// <param name="x">The x-axis number to evaluate.</param>
282282
public static float BackIn(float x)
283283
{
284-
return (Tweening.overshoot + 1.0f) * x * x * x - Tweening.overshoot * x * x;
284+
return (Settings.overshoot + 1.0f) * x * x * x - Settings.overshoot * x * x;
285285
}
286286

287287
/// <summary>
@@ -290,7 +290,7 @@ public static float BackIn(float x)
290290
/// <param name="x">The x-axis number to evaluate.</param>
291291
public static float BackOut(float x)
292292
{
293-
return 1.0f + (Tweening.overshoot + 1.0f) * Mathf.Pow(x - 1.0f, 3.0f) + Tweening.overshoot * Mathf.Pow(x - 1.0f, 2.0f);
293+
return 1.0f + (Settings.overshoot + 1.0f) * Mathf.Pow(x - 1.0f, 3.0f) + Settings.overshoot * Mathf.Pow(x - 1.0f, 2.0f);
294294
}
295295

296296
/// <summary>
@@ -299,7 +299,7 @@ public static float BackOut(float x)
299299
/// <param name="x">The x-axis number to evaluate.</param>
300300
public static float BackInOut(float x)
301301
{
302-
float c2 = Tweening.overshoot * 1.525f;
302+
float c2 = Settings.overshoot * 1.525f;
303303
return x < 0.5f ?
304304
(Mathf.Pow(2.0f * x, 2.0f) * ((c2 + 1.0f) * 2.0f * x - c2)) / 2.0f :
305305
(Mathf.Pow(2.0f * x - 2.0f, 2.0f) * ((c2 + 1.0f) * (x * 2.0f - 2.0f) + c2) + 2.0f) / 2.0f;

Runtime/Settings.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace Zigurous.Tweening
2+
{
3+
/// <summary>
4+
/// Properties for changing global tweening settings.
5+
/// </summary>
6+
public static class Settings
7+
{
8+
/// <summary>
9+
/// The default Ease assigned to every tween.
10+
/// </summary>
11+
public static Ease defaultEase = Ease.QuadOut;
12+
13+
/// <summary>
14+
/// The default amount of seconds a tween takes to complete.
15+
/// </summary>
16+
public static float defaultDuration = 0.3f;
17+
18+
/// <summary>
19+
/// The default amount of seconds before every tween starts.
20+
/// </summary>
21+
public static float defaultDelay = 0.0f;
22+
23+
/// <summary>
24+
/// The overshoot value used in easing functions.
25+
/// </summary>
26+
public static float overshoot = 1.70158f;
27+
28+
/// <summary>
29+
/// The initial amount of tweens memory is allocated for when the system
30+
/// starts. Additional memory will be allocated as needed.
31+
/// </summary>
32+
public static int initialCapacity = 16;
33+
34+
/// <summary>
35+
/// Automatically starts tweens after being created, by default.
36+
/// </summary>
37+
public static bool autoStart = true;
38+
39+
/// <summary>
40+
/// Automatically kills tweens after being completed, by default.
41+
/// </summary>
42+
public static bool autoKill = true;
43+
44+
/// <summary>
45+
/// Keeps tweens in memory to be re-used after being killed, by default.
46+
/// </summary>
47+
public static bool recyclable = true;
48+
}
49+
50+
}

Runtime/Settings.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Tween.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ internal enum Flag
7878
/// <summary>
7979
/// The easing function type used by the tween to animate values.
8080
/// </summary>
81-
public Ease ease = Tweening.defaultEase;
81+
public Ease ease = Settings.defaultEase;
8282

8383
/// <summary>
8484
/// The amount of seconds the tween takes to complete.
8585
/// </summary>
86-
public float duration = Tweening.defaultDuration;
86+
public float duration = Settings.defaultDuration;
8787

8888
/// <summary>
8989
/// The amount of seconds that have elapsed since the tween started.
@@ -99,7 +99,7 @@ internal enum Flag
9999
/// The amount of seconds the tween waits before playing after being
100100
/// started.
101101
/// </summary>
102-
public float delay = Tweening.defaultDelay;
102+
public float delay = Settings.defaultDelay;
103103

104104
/// <summary>
105105
/// The amount of seconds that have elapsed during the tween's delayed
@@ -448,10 +448,10 @@ internal void Reset()
448448
this.state = TweenState.Ready;
449449
this.internalState = InternalTweenState.Queued;
450450

451-
this.ease = Tweening.defaultEase;
452-
this.duration = Tweening.defaultDuration;
451+
this.ease = Settings.defaultEase;
452+
this.duration = Settings.defaultDuration;
453453
this.elapsed = 0.0f;
454-
this.delay = Tweening.defaultDelay;
454+
this.delay = Settings.defaultDelay;
455455
this.delayElapsed = 0.0f;
456456

457457
this.loops = 0;
@@ -461,9 +461,9 @@ internal void Reset()
461461
this.flags = 0;
462462
this.reversed = false;
463463
this.snapping = false;
464-
this.autoStart = Tweening.autoStart;
465-
this.autoKill = Tweening.autoKill;
466-
this.recyclable = Tweening.recyclable;
464+
this.autoStart = Settings.autoStart;
465+
this.autoKill = Settings.autoKill;
466+
this.recyclable = Settings.recyclable;
467467

468468
this.onUpdate = null;
469469
this.onStart = null;

Runtime/TweenManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal sealed class TweenManager : MonoBehaviour
1414
/// <summary>
1515
/// A list of all alive tween objects.
1616
/// </summary>
17-
internal List<Tween> tweens = new List<Tween>(Tweening.initialCapacity);
17+
internal List<Tween> tweens = new List<Tween>(Settings.initialCapacity);
1818

1919
private static bool _isUnloading = false;
2020
private static object _lock = new object();

Runtime/Tweening.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,6 @@ namespace Zigurous.Tweening
88
/// </summary>
99
public static class Tweening
1010
{
11-
/// <summary>
12-
/// The default Ease assigned to every tween.
13-
/// </summary>
14-
public static Ease defaultEase = Ease.QuadOut;
15-
16-
/// <summary>
17-
/// The default amount of seconds a tween takes to complete.
18-
/// </summary>
19-
public static float defaultDuration = 0.3f;
20-
21-
/// <summary>
22-
/// The default amount of seconds before every tween starts.
23-
/// </summary>
24-
public static float defaultDelay = 0.0f;
25-
26-
/// <summary>
27-
/// The default overshoot value used in easing functions.
28-
/// </summary>
29-
public static float overshoot = 1.70158f;
30-
31-
/// <summary>
32-
/// The initial amount of tweens that memory is allocated for when the
33-
/// system starts. Additional memory will be allocated as needed.
34-
/// </summary>
35-
public static int initialCapacity = 16;
36-
37-
/// <summary>
38-
/// Automatically starts tweens after being created, by default.
39-
/// </summary>
40-
public static bool autoStart = true;
41-
42-
/// <summary>
43-
/// Automatically kills tweens after being completed, by default.
44-
/// </summary>
45-
public static bool autoKill = true;
46-
47-
/// <summary>
48-
/// Keeps tweens in memory to be re-used after being killed, by default.
49-
/// </summary>
50-
public static bool recyclable = true;
51-
5211
/// <summary>
5312
/// The number of tweens currently alive (not necessarily active).
5413
/// </summary>

Runtime/TweeningSettings.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Ease defaultEase
2222
set
2323
{
2424
_defaultEase = value;
25-
Tweening.defaultEase = value;
25+
Settings.defaultEase = value;
2626
}
2727
}
2828

@@ -39,7 +39,7 @@ public float defaultDuration
3939
set
4040
{
4141
_defaultDuration = value;
42-
Tweening.defaultDuration = value;
42+
Settings.defaultDuration = value;
4343
}
4444
}
4545

@@ -56,11 +56,11 @@ public float defaultDelay
5656
set
5757
{
5858
_defaultDelay = value;
59-
Tweening.defaultDelay = value;
59+
Settings.defaultDelay = value;
6060
}
6161
}
6262

63-
[Tooltip("The default overshoot value used in easing functions.")]
63+
[Tooltip("The overshoot value used in easing functions.")]
6464
[SerializeField]
6565
private float _overshoot = 1.70158f;
6666

@@ -73,25 +73,25 @@ public float overshoot
7373
set
7474
{
7575
_overshoot = value;
76-
Tweening.overshoot = value;
76+
Settings.overshoot = value;
7777
}
7878
}
7979

80-
[Tooltip("The initial amount of tweens that memory is allocated for when the system starts. Additional memory will be allocated as needed.")]
80+
[Tooltip("The initial amount of tweens memory is allocated for when the system starts. Additional memory will be allocated as needed.")]
8181
[SerializeField]
8282
private int _initialCapacity = 16;
8383

8484
/// <summary>
85-
/// The initial amount of tweens that memory is allocated for when the
86-
/// system starts. Additional memory will be allocated as needed.
85+
/// The initial amount of tweens memory is allocated for when the system
86+
/// starts. Additional memory will be allocated as needed.
8787
/// </summary>
8888
public int initialCapacity
8989
{
9090
get => _initialCapacity;
9191
set
9292
{
9393
_initialCapacity = value;
94-
Tweening.initialCapacity = value;
94+
Settings.initialCapacity = value;
9595
}
9696
}
9797

@@ -108,7 +108,7 @@ public bool autoStart
108108
set
109109
{
110110
_autoStart = value;
111-
Tweening.autoStart = value;
111+
Settings.autoStart = value;
112112
}
113113
}
114114

@@ -125,7 +125,7 @@ public bool autoKill
125125
set
126126
{
127127
_autoKill = value;
128-
Tweening.autoKill = value;
128+
Settings.autoKill = value;
129129
}
130130
}
131131

@@ -142,7 +142,7 @@ public bool recyclable
142142
set
143143
{
144144
_recyclable = value;
145-
Tweening.recyclable = value;
145+
Settings.recyclable = value;
146146
}
147147
}
148148

@@ -158,14 +158,14 @@ private void Awake()
158158

159159
private void UpdateSettings()
160160
{
161-
Tweening.defaultEase = this.defaultEase;
162-
Tweening.defaultDuration = this.defaultDuration;
163-
Tweening.defaultDelay = this.defaultDelay;
164-
Tweening.overshoot = this.overshoot;
165-
Tweening.initialCapacity = this.initialCapacity;
166-
Tweening.autoStart = this.autoStart;
167-
Tweening.autoKill = this.autoKill;
168-
Tweening.recyclable = this.recyclable;
161+
Settings.defaultEase = this.defaultEase;
162+
Settings.defaultDuration = this.defaultDuration;
163+
Settings.defaultDelay = this.defaultDelay;
164+
Settings.overshoot = this.overshoot;
165+
Settings.initialCapacity = this.initialCapacity;
166+
Settings.autoStart = this.autoStart;
167+
Settings.autoKill = this.autoKill;
168+
Settings.recyclable = this.recyclable;
169169
}
170170

171171
}

0 commit comments

Comments
 (0)