English | 한국어
A single-file tweening helper for Unity, built on top of UniRx.
SimpleTweener drives a value over time through Observable.FromCoroutine, handing you the
interpolated float every frame via an onNext callback and signalling the end with onCompleted.
No tween library, no component to attach, no scene setup — one class, one file.
SimpleTweener.EaseOut(0.25f, value => canvasGroup.alpha = value, () => Debug.Log("Done!"));- Single file — drop
SimpleTweener.csinto your project and you are done. - 6 easing curves — Linear, Ease In, Ease Out, Ease In-Out, Bounce In, Bounce Out.
- Value-driven, not property-driven — you get a
float, so you decide what it animates: position, scale, alpha,Image.fillAmount, a score counter, an audio volume fade, anything. - Unscaled time — driven by
Time.unscaledDeltaTime, so tweens keep running whileTime.timeScale == 0. Ideal for pause menus and UI. - No
MonoBehaviourrequired — a plain C# class; the coroutine is hosted by UniRx'sMainThreadDispatcher, so it works from anywhere, including non-MonoBehaviourcode.
| Unity | 5.5 or later (any version supported by UniRx) |
| Dependency | UniRx |
- Install UniRx — via UPM, OpenUPM, or the Asset Store package.
- Copy
SimpleTweener.csanywhere under yourAssets/folder.
That's the whole install. SimpleTweener lives in the global namespace, so no using is needed
beyond UniRx's own.
A tween starts the moment you create it.
void DoTween()
{
// Interpolates 0 -> 1 over 0.25 seconds.
SimpleTweener.EaseIn(0.25f, OnNext, OnCompleted);
}
void OnNext(float value)
{
transform.localScale = Vector3.one * value;
}
void OnCompleted()
{
// Done!
}// Counts 0 -> 100 over 0.25 seconds with an ease in-out curve.
SimpleTweener.EaseInOut(0f, 100f, 0.25f, value => label.text = ((int)value).ToString(), OnCompleted);Every curve exposes an overload for each shape, so you can skip the callback you don't need.
SimpleTweener.BounceOut(0.4f, OnNext); // value only
SimpleTweener.BounceOut(0.4f, OnCompleted); // completion onlyVector3 from = transform.position;
Vector3 to = target.position;
SimpleTweener.EaseOut(0.5f, t => transform.position = Vector3.Lerp(from, to, t));EaseOut and the constructor accept a delay, applied before the curve starts.
// Waits 1 second, then fades 1 -> 0 over 0.3 seconds.
SimpleTweener.EaseOut(1f, 0f, 1f, 0.3f, value => canvasGroup.alpha = value, OnCompleted);Start the next tween from onCompleted.
SimpleTweener.EaseOut(0.2f, t => Scale(t), () =>
{
SimpleTweener.BounceOut(0.3f, t => Bounce(t));
});Linear has no static factory — use the constructor directly.
new SimpleTweener(SimpleTweener.Method.Linear, 0f, 1f, 0f, 0.25f, OnNext, OnCompleted);Available for EaseIn, EaseOut, EaseInOut, BounceIn and BounceOut:
| Signature | Range | Delay |
|---|---|---|
(float duration, Action<float> onNext) |
0 → 1 | none |
(float duration, Action onCompleted) |
0 → 1 | none |
(float duration, Action<float> onNext, Action onCompleted) |
0 → 1 | none |
(float from, float to, float duration, Action<float> onNext, Action onCompleted) |
from → to |
none |
EaseOut is the exception to the last row — it takes a delay as well:
| Signature | Range | Delay |
|---|---|---|
EaseOut(float from, float to, float delay, float duration, Action<float> onNext, Action onCompleted) |
from → to |
delay |
The full surface, and the only way to reach Method.Linear:
public SimpleTweener(
SimpleTweener.Method method,
float from,
float to,
float delay,
float duration,
System.Action<float> onNext,
System.Action onCompleted)| Parameter | Description |
|---|---|
method |
Easing curve — see SimpleTweener.Method. |
from |
Start value. |
to |
End value. |
delay |
Seconds to wait before the curve starts, in unscaled time. |
duration |
Length of the tween in seconds. 0 completes in a single frame. |
onNext |
Called every frame with the interpolated value. May be null. |
onCompleted |
Called once when the tween reaches to. May be null. |
| Method | Curve | Notes |
|---|---|---|
Linear |
t |
Constant speed. Constructor only. |
EaseIn |
1 - sin(π/2 · (1 - t)) |
Slow start, fast finish. |
EaseOut |
sin(π/2 · t) |
Fast start, slow finish. |
EaseInOut |
t - sin(2πt) / 2π |
Slow at both ends. |
BounceIn |
bounce | Bounces at the start. |
BounceOut |
bounce | Bounces at the end (overshoot settle). |
- A tween starts immediately. Constructing a
SimpleTweener— through a factory or the constructor — subscribes right away. There is no separatePlay(). - There is no stop or cancel API. The internal
IDisposableis not exposed, so a tween always runs to completion. If the object you are animating can be destroyed mid-tween, null-check inside youronNext:SimpleTweener.EaseOut(0.3f, t => { if (this != null) canvasGroup.alpha = t; });
- The first emitted value is always
0f, sent before the delay begins — notfrom. With a descending range such asfrom: 100, to: 0, expect a0fon the first frame. Set the initial state yourself before starting the tween if that matters. Linearhas no static factory. Use the constructor.EaseOut's ranged overload takes adelay, unlike the other curves' ranged overloads. Watch the argument order.- Unscaled time is not optional. Every curve uses
Time.unscaledDeltaTime, so tweens ignoreTime.timeScale— including slow-motion effects.
Distributed under the MIT License. See LICENSE for more information.