Skip to content

Commit 93fe228

Browse files
committed
Add new docs manuals
1 parent 56ccc98 commit 93fe228

File tree

13 files changed

+481
-3
lines changed

13 files changed

+481
-3
lines changed
22 KB
Loading

.docfx/manual/callbacks.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Callbacks
2+
3+
Callbacks are used to respond to state changes of a tween. A [TweenCallback](xref:Zigurous.Tweening.TweenCallback) function delegate is invoked for each of the following events:
4+
5+
- [onUpdate](xref:Zigurous.Tweening.Tween.onUpdate): Invoked every time the tween is updated
6+
- [onStart](xref:Zigurous.Tweening.Tween.onStart): Invoked when the tween is started
7+
- [onStop](xref:Zigurous.Tweening.Tween.onStop): Invoked when the tween is stopped
8+
- [onLoop](xref:Zigurous.Tweening.Tween.onLoop): Invoked when the tween is looped
9+
- [onComplete](xref:Zigurous.Tweening.Tween.onComplete): Invoked when the tween is completed
10+
- [onKill](xref:Zigurous.Tweening.Tween.onKill): Invoked when the tween is killed
11+
12+
### Assigning callbacks
13+
14+
Tween callbacks can be assigned with lambdas or normal functions. You can also use [property chaining](property-chaining.md) to make it easier in some cases. Callbacks cannot declare any parameters or return types.
15+
16+
```csharp
17+
// assigning callbacks with lambdas
18+
tween.onUpdate = () => Debug.Log("Updated");
19+
tween.onStart = () => Debug.Log("Started");
20+
tween.onStop = () => Debug.Log("Stopped");
21+
tween.onLoop = () => Debug.Log("Looped");
22+
tween.onComplete = () => Debug.Log("Completed");
23+
tween.onKill = () => Debug.Log("Killed");
24+
```
25+
26+
```csharp
27+
// assigning a callback with a function
28+
Tween tween = transform.TweenPosition(Vector3.zero, 1.0f);
29+
tween.onComplete = SomeFunction;
30+
```

.docfx/manual/easing.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Easing
2+
3+
Easing functions specify the rate of change of a parameter over time.
4+
5+
Objects in real life don’t just start and stop instantly, and almost never move at a constant speed. When we open a drawer, we first move it quickly, and slow it down as it comes out. Drop something on the floor, and it will first accelerate downwards, and then bounce back up after hitting the floor.
6+
7+
The website https://easings.net/ is a good resource to visualize common easing functions.
8+
9+
### Using easing functions
10+
11+
To specify which easing function a tween uses, the property [ease](xref:Zigurous.Tweening.Tween.ease) can be set. This property is backed by a custom enum called [Ease](xref:Zigurous.Tweening.Ease) containing 30+ ease types.
12+
13+
```csharp
14+
tween.ease = Ease.QuadOut;
15+
```
16+
17+
You can also use the easing functions directly through the static class [EaseFunction](xref:Zigurous.Tweening.EaseFunction).<br/>
18+
Every easing function takes the form f(x):
19+
20+
```csharp
21+
public float EaseFunction(float x);
22+
```
23+
24+
### Available Eases
25+
26+
- Linear
27+
- SineIn
28+
- SineOut
29+
- SineInOut
30+
- CubicIn
31+
- CubicOut
32+
- CubicInOut
33+
- QuadIn
34+
- QuadOut
35+
- QuadInOut
36+
- QuartIn
37+
- QuartOut
38+
- QuartInOut
39+
- QuintIn
40+
- QuintOut
41+
- QuintInOut
42+
- ExpoIn
43+
- ExpoOut
44+
- ExpoInOut
45+
- CircIn
46+
- CircOut
47+
- CircInOut
48+
- BackIn
49+
- BackOut
50+
- BackInOut
51+
- ElasticIn
52+
- ElasticOut
53+
- ElasticInOut
54+
- BounceIn
55+
- BounceOut
56+
- BounceInOut

.docfx/manual/index.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@
22

33
The Tweening package provides a system for tweening object properties in Unity. A tween is an animation of a value from a start position to an end position using an easing function, providing a natural sense of motion.
44

5-
The system is lightweight, optimized, type-safe, and memory efficient. Hundreds of pre-defined tweening functions can be called on many common Unity objects, or you can animate anything using generic tweening functions. Tweens can be controlled with many different control methods and various callback functions.
5+
The system is lightweight, optimized, type-safe, and memory efficient. Hundreds of predefined tweening functions can be called on many common Unity objects, or you can animate anything using generic tweening functions. Tweens can be controlled with many different control methods and various callback functions.
6+
7+
### Reference
8+
9+
- [Tweens](tweens.md)
10+
- [Sequences](sequences.md)
11+
- [Easing](easing.md)
12+
- [Callbacks](callbacks.md)
13+
- [Property Chaining](property-chaining.md)
14+
- [Managing Tweens](managing-tweens.md)
15+
- [Supported Types](supported-types.md)
16+
- [Settings](settings.md)

.docfx/manual/managing-tweens.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Managing Tweens
2+
3+
Apart from controlling the state of an individual tween, you can also manage tweens globally using the static class [Tweening](xref:Zigurous.Tweening.Tweening). This class contains functions to change the state of all managed tweens:
4+
5+
```csharp
6+
Tweening.PlayAll();
7+
Tweening.StopAll();
8+
Tweening.RestartAll();
9+
Tweening.CompleteAll();
10+
Tweening.KillAll();
11+
```
12+
13+
You can also get the current amount of tweens:
14+
15+
```csharp
16+
int count = Tweening.Count; // the number of tweens alive (not necessarily active)
17+
int alive = Tweening.ActiveCount; // the number of tween active
18+
```
19+
20+
### Tween Ids
21+
22+
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.
23+
24+
```csharp
25+
Tweening.Play(id);
26+
Tweening.Stop(id);
27+
Tweening.Restart(id);
28+
Tweening.Complete(id);
29+
Tweening.Kill(id);
30+
```
31+
32+
### Target References
33+
34+
Tweens that are created using the shortcut functions will automatically set the id based on the target object being animated. For example, if you tween a transform's position, the id of the tween will get set to the hash code of the transform instance. This then allows you to find tweens using that reference object.
35+
36+
```csharp
37+
Tweening.Play(transform);
38+
Tweening.Stop(transform);
39+
Tweening.Restart(transform);
40+
Tweening.Complete(transform);
41+
Tweening.Kill(transform);
42+
```
43+
44+
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.
45+
46+
```csharp
47+
tween.SetTarget(gameObject);
48+
tween.SetTarget(component);
49+
```
50+
51+
### Scene Unloading
52+
53+
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.
54+
55+
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.
56+
57+
```csharp
58+
tween.sceneIndex = SceneManager.GetActiveScene().buildIndex;
59+
```

.docfx/manual/property-chaining.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Property Chaining
2+
3+
Property/method chaining is a technique that allows multiple properties to be assigned in a single statement without requiring a variable to store the intermediate results. This is most useful when creating new tweens. See the [PropertyChaining](xref:Zigurous.Tweening.PropertyChaining) Scripting API for a full list of properties that can be chained.
4+
5+
### Example
6+
7+
```csharp
8+
transform.TweenPosition(Vector3.zero, 1.0f)
9+
.SetDelay(3.0f)
10+
.SetReversed(true)
11+
.SetEase(Ease.CubicInOut)
12+
.SetLoops(-1, LoopType.PingPong)
13+
.OnLoop(() => Debug.Log('looped!'));
14+
```

.docfx/manual/sequences.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Sequences
2+
3+
A [Sequence](xref:Zigurous.Tweening.Sequence) play a list of tweens in order. The sequence itself maintains its own state and can be controlled the same as any other tween (although not every property has an effect).
4+
5+
### Creating a sequence
6+
7+
Sequences can be created in one of two ways. You can simply instantiate one like any other class. However, it is recommended to create one using the static class [Tweening](xref:Zigurous.Tweening.Tweening) so it can reuse recycled sequences.
8+
9+
```csharp
10+
Sequence sequence = Tweening.Sequence(); // Recommended
11+
Sequence sequence = new Sequence(); // Not recommended
12+
```
13+
14+
### Adding tweens
15+
16+
Tweens can either be added to the end or beginning of the sequence using `Append` or `Prepend`, respectively. Tweens will automatically start and stop as needed based on the state of the sequence. You should not manually transition a tween to playing or stopping (or any other state), instead change the state of the sequence. You can still customize individual tween properties, like duration, ease, callbacks, etc.
17+
18+
```csharp
19+
Sequence sequence = Tweening.Sequence();
20+
21+
// Adds a tween to the end of the sequence
22+
sequence.Append(transform.TweenPosition(Vector3.zero, 1.0f));
23+
sequence.Append(transform.TweenRotation(Quaternion.identity, 1.0f));
24+
25+
// Adds a tween to the beginning of the sequence
26+
sequence.Prepend(transform.TweenScale(Vector3.one, 1.0f));
27+
```
28+
29+
### State control
30+
31+
Sequences can be controlled the same way as any other tween, meaning you can play, stop, restart, loop, kill etc.
32+
33+
```csharp
34+
Sequence sequence = Tweening.Sequence();
35+
sequence.SetLoops(-1, LoopType.PingPong);
36+
sequence.OnComplete(() => Debug.Log("sucess!"));
37+
sequence.Play();
38+
```

.docfx/manual/settings.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Settings
2+
3+
The Tweening package provides a few global settings that can be modified. Settings can either be changed through a static class, or through a mono behavior. The following settings are available:
4+
5+
- [defaultEase](xref:Zigurous.Tweening.Tweening.defaultEase): The default [Ease](xref:Zigurous.Tweening.Ease) assigned to every tween ([Ease.QuadOut](xref:Zigurous.Tweening.Ease.QuadOut)). The ease used by a tween can be set manually if desired.
6+
- [defaultDuration](xref:Zigurous.Tweening.Tweening.defaultDuration): The default amount of seconds a tween takes to complete (`0.3`). The duration of a tween can be set manually if desired.
7+
- [defaultDelay](xref:Zigurous.Tweening.Tweening.defaultDelay): The default amount of seconds before every tween starts (`0`). The delay of a tween can be set manually if desired.
8+
- [overshoot](xref:Zigurous.Tweening.Tweening.overshoot): The overshoot value used in easing functions (`1.70158`).
9+
- [initialCapacity](xref:Zigurous.Tweening.Tweening.initialCapacity): The initial amount of tweens memory is allocated for when the system starts (`16`). Additional memory will be allocated as needed.
10+
- [autoStart](xref:Zigurous.Tweening.Tweening.autoStart): Automatically starts tweens after being created (`true`). This is can be turned on/off manually per tween if desired.
11+
- [autoKill](xref:Zigurous.Tweening.Tweening.autoKill): Automatically kills tweens after being completed (`true`). This is can be turned on/off manually per tween if desired.
12+
- [recyclable](xref:Zigurous.Tweening.Tweening.recyclable): Keeps tweens in memory to be re-used after being killed (`true`). This can be turned on/off manually per tween if desired.
13+
14+
### Changing settings with code
15+
16+
Tweening settings can be changed through the static class [Settings](xref:Zigurous.Tweening.Settings).<br/>
17+
Below are all of the settings and their default values:
18+
19+
```csharp
20+
Settings.defaultEase = Ease.QuadOut;
21+
Settings.defaultDuration = 0.3f;
22+
Settings.defaultDelay = 0.0f;
23+
Settings.overshoot = 1.70158f;
24+
Settings.initialCapacity = 16;
25+
Settings.autoStart = true;
26+
Settings.autoKill = true;
27+
Settings.recyclable = true;
28+
```
29+
30+
### Changing settings in the editor
31+
32+
The Tweening package includes a mono behaviour called [TweeningSettings](xref:Zigurous.Tweening.TweeningSettings) that can be added to your scene. This is generally used to provide a simple interface for changing settings in the Unity editor rather than through code. You can, of course, still use this behavior to change settings at runtime if desired.
33+
34+
![](../images/tweening-settings.png)

.docfx/manual/supported-types.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Supported Types
2+
3+
### Generics
4+
5+
When creating tweens using the generic functions, the following types of values can be animated:
6+
7+
- `float`
8+
- `double`
9+
- `long`
10+
- `int`
11+
- `Vector2`
12+
- `Vector2Int`
13+
- `Vector3`
14+
- `Vector3Int`
15+
- `Vector4`
16+
- `Quaternion`
17+
- `Rect`
18+
- `Color`
19+
20+
### Shortcuts
21+
22+
All of the following types offer shortcut functions for creating tweens:
23+
24+
- AimConstraint
25+
- AnchoredJoint2D
26+
- Animator
27+
- AreaEffector2D
28+
- AspectRatioFitter
29+
- AudioChorusFilter
30+
- AudioDistortionFilter
31+
- AudioEchoFilter
32+
- AudioHighPassFilter
33+
- AudioListener
34+
- AudioLowPassFilter
35+
- AudioReverbFilter
36+
- AudioReverbZone
37+
- AudioSource
38+
- BoxCollider
39+
- BoxCollider2D
40+
- BuoyancyEffector2D
41+
- Camera
42+
- Canvas
43+
- CanvasGroup
44+
- CanvasScaler
45+
- CapsuleCollider
46+
- CapsuleCollider2D
47+
- CharacterController
48+
- CharacterJoint
49+
- CircleCollider2D
50+
- Cloth
51+
- Collider
52+
- Collider2D
53+
- CompositeCollider2D
54+
- ConfigurableJoint
55+
- ConstantForce
56+
- ConstantForce2D
57+
- DistanceJoint2D
58+
- EdgeCollider2D
59+
- FixedJoint2D
60+
- FrictionJoint2D
61+
- Graphic
62+
- Grid
63+
- GridLayoutGroup
64+
- HorizontalOrVerticalLayoutGroup
65+
- Joint
66+
- Joint2D
67+
- LensFlare
68+
- Light
69+
- LineRenderer
70+
- LookAtConstraint
71+
- Material
72+
- NavMeshAgent
73+
- NavMeshObstacle
74+
- OcclusionArea
75+
- ParentConstraint
76+
- ParticleSystem
77+
- ParticleSystemForceField
78+
- PhysicMaterial
79+
- PhysicsMaterial2D
80+
- PlatformEffector2D
81+
- PointEffector2D
82+
- PositionConstraint
83+
- Projector
84+
- RectMask2D
85+
- RectOffset
86+
- RectTransform
87+
- ReflectionProbe
88+
- RelativeJoint2D
89+
- Rigidbody
90+
- Rigidbody2D
91+
- RotationConstraint
92+
- ScaleConstraint
93+
- Scrollbar
94+
- ScrollRect
95+
- Shadow
96+
- Slider
97+
- SphereCollider
98+
- SpringJoint
99+
- SpringJoint2D
100+
- SpriteMask
101+
- SpriteRenderer
102+
- SpriteShapeRenderer
103+
- SurfaceEffector2D
104+
- TargetJoint2D
105+
- Text
106+
- TextMesh
107+
- Tilemap
108+
- TrailRenderer
109+
- Transform
110+
- VideoPlayer
111+
- WheelCollider
112+
- WindZone

.docfx/manual/toc.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,21 @@
22
href: index.md
33
- name: Installation
44
href: installation.md
5+
- name: Reference
6+
items:
7+
- name: Tweens
8+
href: tweens.md
9+
- name: Sequences
10+
href: sequences.md
11+
- name: Easing
12+
href: easing.md
13+
- name: Callbacks
14+
href: callbacks.md
15+
- name: Property Chaining
16+
href: property-chaining.md
17+
- name: Managing Tweens
18+
href: managing-tweens.md
19+
- name: Supported Types
20+
href: supported-types.md
21+
- name: Settings
22+
href: settings.md

0 commit comments

Comments
 (0)