Home

Awesome

Ultra Lightweight Tweening Engine for Unity (Uween)

Uween is a simple tween library for Unity.

Features

Simple & Lightweight

Uween is super simple. Core system (Tween.cs) is about 100 lines code. Simple is powerful.

Easy to use

// Go to x:100 in 1 second.
TweenX.Add(gameObject, 1f, 100f);

That's all.

Fluent syntax

// Go to x:100 in 1 second with in-out-sine easing and 5 sec delay.
// Then do a next motion.
TweenX.Add(gameObject, 1f, 100f).EaseInOutSine().Delay(0.5f).Then(next_motion);

Unity friendly

Uween's design is completely focusing on Unity. It works as a simple Unity component and follows a Unity execution flow.

Setup

Simply copy a Uween directory to your Unity project. Uween - Example directory is not needed.

If you don't use uGUI (requires Unity >= 4.6), delete the following files:

Examples

Open a Uween - Example/Scenes/Example.unity scene. All code is written in Uween - Example/Scripts/Example.cs.

Quick help

Import

Add using Uween; in your script.

using UnityEngine;
using System.Collections;
using Uween;

Starting tween

Call a tween class's Add method.

TweenX.Add(g, 0.3f, 120f);
TweenY.Add(g, 0.5f, 240f);

At least Add method has two parameters:

  1. GameObject - Tweening target.
  2. float - Tweening duration (sec).

and has more extra parameters depending on tween classes. For example, TweenX has a destination x value as 3rd parameter.

Tween classes

Note: g is GameObject, d is duration.

Fluent syntax

All the following feature can be called with fluent syntax. (Fluent syntax is also known as method chain)

Like:

TweenX.Add(gameObject, 1f, 100f).EaseInOutSine().Delay(0.5f).Then(next_motion);

Easings

You can use all of Robert Penner's easings:

Delay

You can insert a delay time before starting tween.

Callback

You can set to call method you like when tween completed.

Initial value

You can set a initial value. It will be apply immediately to GameObject (before delay).

Relative value

You can set a destination or initial value relative from current value.

To current value

If you don't set a destination value, it will automatically set as a current value.

// From 100px to current position
TweenX.Add(gameObject, 1f).From(100f);

Pause/Resume

You can pause/resume active tweens in a GameObject.

TweenNull

TweenNull will not tween any value. You can use this class for wait, delayed callback, etc...

// Callback after 3sec.
TweenNull(g, 3f).Then(callback)

License

Copyright 2014 Oink Games, Inc. and other contributors.

Code licensed under the MIT License: http://opensource.org/licenses/MIT