Skip to content

Commit 656e269

Browse files
committed
Merge branch 'release/3.0.0'
2 parents d0b098f + 52c0d12 commit 656e269

File tree

118 files changed

+1842
-1722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1842
-1722
lines changed

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,35 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.0] - 2023/10/22
9+
10+
### Added
11+
12+
- Support for creating generic tweens with `short` values
13+
- New extension methods for tweening `MaterialPropertyBlock`
14+
- New extension method `Shadow.TweenAlpha`
15+
- New interface `ITweenEventHandler` that can be used to respond to tween events without allocating GC from delegates
16+
- New utility functions to change color components
17+
18+
### Changed
19+
20+
- Refactored tween extensions to not use closures to reduce GC allocations
21+
- Source objects are now cached in the tween and passed to the getter/setter functions
22+
- Changed property name casing to match C# conventions
23+
- Renamed `Transform.TweenScale` to `Transform.TweenLocalScale`
24+
- Renamed `Shadow.TweenEffectColor` to `Shadow.TweenColor`
25+
- Renamed `Shadow.TweenEffectDistance` to `Shadow.TweenDistance`
26+
27+
### Fixed
28+
29+
- Fixed tweens not updating when the duration is set to zero
30+
- Fixed interpolation snapping to round to the nearest integer instead of always rounding down
31+
832
## [2.6.1] - 2022/05/11
933

1034
### Fixed
1135

12-
- Prevented errors caused when tweens are created while the game or scene is unloading
36+
- Prevented errors when tweens are created while the game or scene is unloading
1337

1438
### Changed
1539

Documentation~/articles/callbacks.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

Documentation~/articles/events.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
slug: "/manual/events"
3+
---
4+
5+
# Events
6+
7+
Various events are invoked throughout the tween lifecycle. A [TweenCallback](/api/Zigurous.Tweening/TweenCallback) function delegate can be used to respond to the following events:
8+
9+
- [onUpdate](/api/Zigurous.Tweening/Tween/onUpdate): Invoked every time the tween is updated
10+
- [onStart](/api/Zigurous.Tweening/Tween/onStart): Invoked when the tween is started
11+
- [onStop](/api/Zigurous.Tweening/Tween/onStop): Invoked when the tween is stopped
12+
- [onLoop](/api/Zigurous.Tweening/Tween/onLoop): Invoked when the tween is looped
13+
- [onComplete](/api/Zigurous.Tweening/Tween/onComplete): Invoked when the tween is completed
14+
- [onKill](/api/Zigurous.Tweening/Tween/onKill): Invoked when the tween is killed
15+
16+
<hr/>
17+
18+
## 🗣️ Assigning callbacks
19+
20+
Tween callbacks can be assigned with delegates or lambdas. They have no parameters or return types. You can also use [property chaining](/manual/property-chaining) to make it easier to set multiple callbacks.
21+
22+
```csharp
23+
// assigning callbacks with functions
24+
tween.onUpdate += OnTweenUpdated
25+
tween.onStart += OnTweenStarted;
26+
tween.onStop += OnTweenStopped;
27+
tween.onLoop += OnTweenLooped;
28+
tween.onComplete += OnTweenCompleted;
29+
tween.onKill += OnTweenKilled;
30+
```
31+
32+
```csharp
33+
// assigning callbacks with lambdas
34+
tween.onUpdate += () => Debug.Log("Updated");
35+
tween.onStart += () => Debug.Log("Started");
36+
tween.onStop += () => Debug.Log("Stopped");
37+
tween.onLoop += () => Debug.Log("Looped");
38+
tween.onComplete += () => Debug.Log("Completed");
39+
tween.onKill += () => Debug.Log("Killed");
40+
```
41+
42+
```csharp
43+
// assigning callbacks with property chaining
44+
transform.TweenPosition(Vector3.zero, 1f)
45+
.OnUpdate(OnTweenUpdated)
46+
.OnStart(OnTweenStarted)
47+
.OnStop(OnTweenStopped)
48+
.OnLoop(OnTweenLooped)
49+
.OnComplete(OnTweenCompleted)
50+
.OnKill(OnTweenKilled);
51+
```
52+
53+
## 🎫 Event Handler
54+
55+
One drawback of using delegates is that it produces GC allocations. If you are highly concerned about performance, you can use the [ITweenEventHandler](/api/Zigurous.Tweening/ITweenEventHandler) interface to avoid allocations.
56+
57+
```csharp
58+
public class Example : MonoBehaviour, ITweenEventHandler
59+
{
60+
private void Start()
61+
{
62+
transform.TweenPosition(Vector3.zero, 1f)
63+
.SetEventHandler(this);
64+
}
65+
66+
public void OnTweenUpdate(Tween tween)
67+
{
68+
Debug.Log("Updated");
69+
}
70+
71+
public void OnTweenStart(Tween tween)
72+
{
73+
Debug.Log("Started");
74+
}
75+
76+
public void OnTweenStop(Tween tween)
77+
{
78+
Debug.Log("Stopped");
79+
}
80+
81+
public void OnTweenLoop(Tween tween)
82+
{
83+
Debug.Log("Looped");
84+
}
85+
86+
public void OnTweenComplete(Tween tween)
87+
{
88+
Debug.Log("Completed");
89+
}
90+
91+
public void OnTweenKill(Tween tween)
92+
{
93+
Debug.Log("Killed");
94+
}
95+
}

Documentation~/articles/index.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,32 @@ The system is lightweight, optimized, type-safe, and memory efficient. Hundreds
1010

1111
<hr/>
1212

13-
## 📌 Overview
13+
## Overview
1414

15-
- [Scripting API](/api/Zigurous.Tweening)
16-
- [Installation](/manual/installation)
17-
- [Changelog](/changelog)
18-
- [License](/license)
15+
#### ⚙️ [Installation](/installation)
16+
17+
#### 🧰 [Scripting API](/api/Zigurous.Tweening)
18+
19+
#### 📋 [Changelog](/changelog)
20+
21+
#### ⚖️ [License](/license)
1922

2023
<hr/>
2124

22-
## 📖 Reference
25+
## Reference
26+
27+
#### 🚀 [Tweens](/manual/tweens)
28+
29+
#### 🧬 [Sequences](/manual/sequences)
30+
31+
#### 〽️ [Easing](/manual/easing)
32+
33+
#### 🎫 [Events](/manual/events)
34+
35+
#### ⛓️ [Property Chaining](/manual/property-chaining)
36+
37+
#### 🏷️ [Managing Tweens](/manual/managing-tweens)
38+
39+
#### 💠 [Supported Types](/manual/supported-types)
2340

24-
- [Tweens](/manual/tweens)
25-
- [Sequences](/manual/sequences)
26-
- [Easing](/manual/easing)
27-
- [Callbacks](/manual/callbacks)
28-
- [Property Chaining](/manual/property-chaining)
29-
- [Managing Tweens](/manual/managing-tweens)
30-
- [Supported Types](/manual/supported-types)
31-
- [Settings](/manual/settings)
41+
#### 🎛️ [Settings](/manual/settings)

Documentation~/articles/managing-tweens.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Tweening.KillAll();
1717
You can also get the current amount of tweens:
1818

1919
```csharp
20-
int count = Tweening.Count; // the number of tweens alive (not necessarily active)
21-
int alive = Tweening.ActiveCount; // the number of tween active
20+
int count = Tweening.Count; // the number of alive tweens (not necessarily active)
21+
int activeCount = Tweening.ActiveCount; // the number of active tweens
2222
```
2323

2424
<hr/>
2525

2626
## 🏷️ Tween Ids
2727

28-
You can also target specific tweens by id. Every tween has an `id` property which allows you to distinguish it from others. However, this is not required, nor is the id unique. The id is set automatically unless you create tweens manually using the generic approach.
28+
You can also target specific tweens by id. Every tween has an `id` property which allows you to distinguish it from others. However, this is not required, nor is the id unique. The id is set automatically unless you create tweens manually using the generic approach. All ids are implement as `int` values.
2929

3030
```csharp
3131
Tweening.Play(id);
@@ -35,6 +35,12 @@ Tweening.Complete(id);
3535
Tweening.Kill(id);
3636
```
3737

38+
To manually set the id of a tween:
39+
40+
```csharp
41+
tween.id = id;
42+
```
43+
3844
<hr/>
3945

4046
## 🎯 Target References
@@ -49,18 +55,18 @@ Tweening.Complete(transform);
4955
Tweening.Kill(transform);
5056
```
5157

52-
If you create tweens manually using the generic approach, you should indicate to the tween what its target game object or component is, which will set the id of the tween based on that object's hash code.
58+
If you create tweens manually using the generic approach, you should indicate to the tween what game object or component it is referencing. This sets both the id (see above) and scene index (see below) of the tween.
5359

5460
```csharp
55-
tween.SetTarget(gameObject);
56-
tween.SetTarget(component);
61+
tween.SetReference(gameObject);
62+
tween.SetReference(component);
5763
```
5864

5965
<hr/>
6066

6167
## 🎬 Scene Unloading
6268

63-
Tweens will be killed automatically when the scene they are apart of is unloaded which prevents errors. However, this only works automatically if the tween knows which target object it is animating (see above). You should only need to worry about this if you are creating tweens manually using the generic approach.
69+
Tweens will be killed automatically when the scene they are apart of is unloaded which prevents errors accessing objects that have been destroyed. However, this only works automatically if the tween knows which target object it is animating (see above). You should only need to worry about this if you are creating tweens manually using the generic approach.
6470

6571
Make sure to kill your tweens before transitioning scenes, or set the target reference as outlined above. You can also manually set the scene index if desired.
6672

Documentation~/articles/property-chaining.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,25 @@ Property/method chaining is a technique that allows multiple properties to be as
88

99
<hr/>
1010

11-
## ⛓️ Example
11+
## ⛓️ Examples
1212

1313
```csharp
14+
// using a tween shortcut
1415
transform.TweenPosition(Vector3.zero, 1f)
1516
.SetDelay(3f)
16-
.SetReversed(true)
17+
.SetReversed()
1718
.SetEase(Ease.CubicInOut)
1819
.SetLoops(-1, LoopType.PingPong)
1920
.OnLoop(() => Debug.Log("looped!"));
2021
```
22+
23+
```csharp
24+
// building from scratch
25+
Tween tween = new Tweener<Transform, Vector3>(transform)
26+
.SetGetter((target) => target.position)
27+
.SetSetter((target, value) => target.position = value)
28+
.SetEndValue(Vector3.zero)
29+
.SetDuration(1f)
30+
.SetEase(Ease.QuadOut)
31+
.OnComplete(() => Debug.Log("complete!"));
32+
```

Documentation~/articles/sequences.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ Sequences can be controlled the same way as any other tween, meaning you can pla
4343
```csharp
4444
Sequence sequence = Tweening.Sequence();
4545
sequence.SetLoops(-1, LoopType.PingPong);
46-
sequence.OnComplete(() => Debug.Log("sucess!"));
46+
sequence.OnComplete(() => Debug.Log("success!"));
4747
sequence.Play();
4848
```

Documentation~/articles/settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Settings.recyclable = true;
3535

3636
<hr/>
3737

38-
## 🖥️ Changing settings in the editor
38+
## 🎛️ Changing settings in the editor
3939

4040
The [Settings](/api/Zigurous.Tweening/Settings) class can also be used as a MonoBehaviour added to your scene. This is generally used to provide a simple interface for changing settings in the Unity editor rather than with code. You can, of course, still use this behavior to change settings at runtime if desired, in which case there is a function to set each respective setting.
4141

Documentation~/articles/supported-types.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ When creating tweens using the generic functions, the following types of values
1010

1111
- `float`
1212
- `double`
13-
- `long`
1413
- `int`
14+
- `long`
15+
- `short`
1516
- `Vector2`
1617
- `Vector2Int`
1718
- `Vector3`
@@ -75,6 +76,7 @@ All of the following types offer shortcut functions for creating tweens:
7576
- `LineRenderer`
7677
- `LookAtConstraint`
7778
- `Material`
79+
- `MaterialPropertyBlock`
7880
- `NavMeshAgent`
7981
- `NavMeshObstacle`
8082
- `OcclusionArea`

0 commit comments

Comments
 (0)