- Developed by Dented Pixel
API Docs for: LeanTween 2.46

Support LeanTween!

Maintaining and adding new features takes time, your support is appreciated.

Show:

LTDescr Class

Defined in: LTDescr.cs:5

Internal Representation of a Tween

This class represents all of the optional parameters you can pass to a method (it also represents the internal representation of the tween).

Optional Parameters are passed at the end of every method:

  Example:
  LeanTween.moveX( gameObject, 1f, 1f).setEase( LeanTweenType.easeInQuad ).setDelay(1f);

You can pass the optional parameters in any order, and chain on as many as you wish.
You can also pass parameters at a later time by saving a reference to what is returned.

Retrieve a unique id for the tween by using the "id" property. You can pass this to LeanTween.pause, LeanTween.resume, LeanTween.cancel, LeanTween.isTweening methods

  

Example:

  int id = LeanTween.moveX(gameObject, 1f, 3f).id;

  // pause a specific tween
  LeanTween.pause(id);
  // resume later
  LeanTween.resume(id);
  // check if it is tweening before kicking of a new tween
  if( LeanTween.isTweening( id ) ){
      LeanTween.cancel( id );
      LeanTween.moveZ(gameObject, 10f, 3f);
  }

Constructor

LTDescr

()

Defined in LTDescr.cs:5

Methods

pause

() LTDescr

Defined in LTDescr.cs:1160

Pause a tween

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

resume

() LTDescr

Defined in LTDescr.cs:1175

Resume a paused tween

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

setAxis

(
  • axis
)
LTDescr

Defined in LTDescr.cs:1187

Set Axis optional axis for tweens where it is relevant

Parameters:

  • axis Vector3

    either the tween rotates around, or the direction it faces in the case of setOrientToPath

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);

setDelay

(
  • float
)
LTDescr

Defined in LTDescr.cs:1201

Delay the start of a tween

Parameters:

  • float Float

    time The time to complete the tween in

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setDelay( 1.5f );

setDirection

(
  • direction:float
)
LTDescr

Defined in LTDescr.cs:2236

Set the direction of a tween -1f for backwards 1f for forwards (currently only bezier and spline paths are supported)

Parameters:

  • direction:float Float

    the direction that the tween should run, -1f for backwards 1f for forwards

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveSpline(gameObject, new Vector3[]{new Vector3(0f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,0f),new Vector3(1f,0f,1f)}, 1.5f).setDirection(-1f);

setEase

(
  • easeType:LeanTweenType
)
LTDescr

Defined in LTDescr.cs:1216

Parameters:

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce );

setEase (AnimationCurve)

(
  • easeDefinition:AnimationCurve
)
LTDescr

Defined in LTDescr.cs:1666

Set the type of easing used for the tween with a custom curve.

Parameters:

  • easeDefinition:AnimationCurve AnimationCurve

    an AnimationCure that describes the type of easing you want, this is great for when you want a unique type of movement

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce );

setFrom

(
  • from:Vector3
)
LTDescr

Defined in LTDescr.cs:1707

Set the beginning of the tween

Parameters:

  • from:Vector3 Vector3

    the point you would like the tween to start at

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LTDescr descr = LeanTween.move( cube, Vector3.up, new Vector3(1f,3f,0f), 1.0f ).setFrom( new Vector3(5f,10f,3f) );

setIgnoreTimeScale

(
  • useUnScaledTime:bool
)
LTDescr

Defined in LTDescr.cs:1826

Set ignore time scale when tweening an object when you want the animation to be time-scale independent (ignores the Time.timeScale value). Great for pause screens, when you want all other action to be stopped (or slowed down)

Parameters:

  • useUnScaledTime:bool Bool

    whether to use the unscaled time or not

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setIgnoreTimeScale( true );

setLoopClamp

(
  • loops:int
)
LTDescr

Defined in LTDescr.cs:1875

When the animation gets to the end it starts back at where it began

Parameters:

  • loops:int Int

    (defaults to -1) how many times you want the loop to happen (-1 for an infinite number of times)

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopClamp( 2 );

setLoopOnce

() LTDescr

Defined in LTDescr.cs:1866

No looping involved, just run once (the default)

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopOnce();

setLoopPingPong

(
  • loops:int
)
LTDescr

Defined in LTDescr.cs:1894

When the animation gets to the end it then tweens back to where it started (and on, and on)

Parameters:

  • loops:int Int

    (defaults to -1) how many times you want the loop to happen in both directions (-1 for an infinite number of times). Passing a value of 1 will cause the object to go towards and back from it's destination once.

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopPingPong( 2 );

setOnComplete

(
  • onComplete:Action
)
LTDescr

Defined in LTDescr.cs:1914

Have a method called when the tween finishes

Parameters:

  • onComplete:Action Action

    the method that should be called when the tween is finished ex: tweenFinished(){ }

Returns:

LTDescr:

LTDescr an object that distinguishes the tween

Example:

LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished );

setOnComplete (object)

(
  • onComplete:Action<object>
)
LTDescr

Defined in LTDescr.cs:1928

Have a method called when the tween finishes

Parameters:

  • onComplete:Action<object> Action

    the method that should be called when the tween is finished ex: tweenFinished( object myObj ){ }

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished );

    setOnCompleteOnRepeat

    (
    • isOn:bool
    )
    LTDescr

    Defined in LTDescr.cs:2174

    Set the onComplete method to be called at the end of every loop cycle (also applies to the delayedCall method)

    Parameters:

    • isOn:bool Bool

      does call onComplete on every loop cycle

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.delayedCall(gameObject,0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true);

    setOnCompleteOnStart

    (
    • isOn:bool
    )
    LTDescr

    Defined in LTDescr.cs:2187

    Set the onComplete method to be called at the beginning of the tween (it will still be called when it is completed as well)

    Parameters:

    • isOn:bool Bool

      does call onComplete at the start of the tween

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.delayedCall(gameObject, 2f, ()=>{
    // Flash an object 5 times  LeanTween.alpha(gameObject, 0f, 1f);
     LeanTween.alpha(gameObject, 1f, 0f).setDelay(1f);
    }).setOnCompleteOnStart(true).setRepeat(5);

    setOnCompleteParam

    (
    • onComplete:object
    )
    LTDescr

    Defined in LTDescr.cs:1949

    Pass an object to along with the onComplete Function

    Parameters:

    • onComplete:object Object

      an object that

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.delayedCall(1.5f, enterMiniGameStart).setOnCompleteParam( new object[]{""+5} );

    void enterMiniGameStart( object val ){
     object[] arr = (object [])val;
     int lvl = int.Parse((string)arr[0]);
    }

    setOnStart

    (
    • onStart:Action<>
    )
    LTDescr

    Defined in LTDescr.cs:2220

    Have a method called when the tween starts

    Parameters:

    • onStart:Action<> Action<>

      the method that should be called when the tween is starting ex: tweenStarted( ){ }

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    C#:
    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnStart( ()=>{ Debug.Log("I started!"); }); Javascript:
    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnStart( function(){ Debug.Log("I started!"); } );

    setOnUpdate

    (
    • onUpdate:Action<float>
    )
    LTDescr

    Defined in LTDescr.cs:1968

    Have a method called on each frame that the tween is being animated (passes a float value)

    Parameters:

    • onUpdate:Action<float> Action

      a method that will be called on every frame with the float value of the tweened object

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );

    void tweenMoved( float val ){ }

    setOnUpdate (object)

    (
    • onUpdate:Action<float,object>
    )
    LTDescr

    Defined in LTDescr.cs:2030

    Have a method called on each frame that the tween is being animated (passes a float value and a object)

    Parameters:

    • onUpdate:Action<float,object> Action

      a method that will be called on every frame with the float value of the tweened object, and an object of the person's choosing

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved ).setOnUpdateParam( myObject );

    void tweenMoved( float val, object obj ){ }

    setOnUpdate (Vector3)

    (
    • onUpdate:Action<Vector3>
    )
    LTDescr

    Defined in LTDescr.cs:2064

    Have a method called on each frame that the tween is being animated (passes a float value)

    Parameters:

    • onUpdate:Action<Vector3> Action

      a method that will be called on every frame with the float value of the tweened object

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );

    void tweenMoved( Vector3 val ){ }

    setOnUpdateParam

    (
    • onUpdateParam:object
    )
    LTDescr

    Defined in LTDescr.cs:2084

    Have an object passed along with the onUpdate method

    Parameters:

    • onUpdateParam:object Object

      an object that will be passed along with the onUpdate method

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved ).setOnUpdateParam( myObject );

    void tweenMoved( float val, object obj ){ }

    setOrientToPath

    (
    • doesOrient:bool
    )
    LTDescr

    Defined in LTDescr.cs:2099

    While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon

    Parameters:

    • doesOrient:bool Bool

      whether the gameobject will orient to the path it is animating along

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);

    setOrientToPath2d

    (
    • doesOrient:bool
    )
    LTDescr

    Defined in LTDescr.cs:2118

    While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon

    Parameters:

    • doesOrient:bool Bool

      whether the gameobject will orient to the path it is animating along

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath2d(true).setAxis(Vector3.forward);

    setOvershoot

    (
    • overshoot:float
    )
    LTDescr

    Defined in LTDescr.cs:1627

    Set how far past a tween will overshoot for certain ease types (compatible: easeInBack, easeInOutBack, easeOutBack, easeOutElastic, easeInElastic, easeInOutElastic).

    Parameters:

    • overshoot:float Float

      how far past the destination it will go before settling in

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutBack ).setOvershoot(2f);

    setPassed

    (
    • passedTime:float
    )
    LTDescr

    Defined in LTDescr.cs:1747

    Set the point of time the tween will start in

    Parameters:

    • passedTime:float Float

      the length of time in seconds the tween will start in

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    int tweenId = LeanTween.moveX(gameObject, 5f, 2.0f ).id;
    // Later
    LTDescr descr = description( tweenId );
    descr.setPassed( 1f );

    setPeriod

    (
    • period:float
    )
    LTDescr

    Defined in LTDescr.cs:1640

    Set how short the iterations are for certain ease types (compatible: easeOutElastic, easeInElastic, easeInOutElastic).

    Parameters:

    • period:float Float

      how short the iterations are that the tween will animate at (default 0.3f)

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutElastic ).setPeriod(0.3f);

    setPoint

    (
    • point:Vector3
    )
    LTDescr

    Defined in LTDescr.cs:2151

    Set the point at which the GameObject will be rotated around

    Parameters:

    • point:Vector3 Vector3

      point at which you want the object to rotate around (local space)

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.rotateAround( cube, Vector3.up, 360.0f, 1.0f ) .setPoint( new Vector3(1f,0f,0f) ) .setEase( LeanTweenType.easeInOutBounce );

    setRecursive

    (
    • useRecursion:bool
    )
    LTDescr

    Defined in LTDescr.cs:2268

    Set whether or not the tween will recursively effect an objects children in the hierarchy

    Parameters:

    • useRecursion:bool Bool

      whether the tween will recursively effect an objects children in the hierarchy

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.alpha(gameObject, 0f, 1f).setRecursive(true);

    setRepeat

    (
    • repeatNum:int
    )
    LTDescr

    Defined in LTDescr.cs:1796

    Set the tween to repeat a number of times.

    Parameters:

    • repeatNum:int Int

      the number of times to repeat the tween. -1 to repeat infinite times

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong();

    setScale

    (
    • scale:float
    )
    LTDescr

    Defined in LTDescr.cs:1653

    Set how large the effect is for certain ease types (compatible: punch, shake, animation curves).

    Parameters:

    • scale:float Float

      how much the ease will be multiplied by (default 1f)

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.punch ).setScale(2f);

    setSpeed

    (
    • speed:float
    )
    LTDescr

    Defined in LTDescr.cs:1781

    Set the finish time of the tween

    Parameters:

    • speed:float Float

      the speed in unity units per second you wish the object to travel (overrides the given time)

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveLocalZ( gameObject, 10f, 1f).setSpeed(0.2f) // the given time is ignored when speed is set

    setTime

    (
    • finishTime:float
    )
    LTDescr

    Defined in LTDescr.cs:1763

    Set the finish time of the tween

    Parameters:

    • finishTime:float Float

      the length of time in seconds you wish the tween to complete in

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    int tweenId = LeanTween.moveX(gameObject, 5f, 2.0f ).id;
    // Later
    LTDescr descr = description( tweenId );
    descr.setTime( 1f );

    setTo

    (
    • to:Vector3
    )
    LTDescr

    Defined in LTDescr.cs:1681

    Set the end that the GameObject is tweening towards

    Parameters:

    • to:Vector3 Vector3

      point at which you want the tween to reach

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LTDescr descr = LeanTween.move( cube, Vector3.up, new Vector3(1f,3f,0f), 1.0f ).setEase( LeanTweenType.easeInOutBounce );
    // Later your want to change your destination or your destiation is constantly moving
    descr.setTo( new Vector3(5f,10f,3f) );

    setUseFrames

    (
    • useFrames:bool
    )
    LTDescr

    Defined in LTDescr.cs:1840

    Use frames when tweening an object, when you don't want the animation to be time-frame independent...

    Parameters:

    • useFrames:bool Bool

      whether to use estimated time or not

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setUseFrames( true );

    updateNow

    () LTDescr

    Defined in LTDescr.cs:925

    If you need a tween to happen immediately instead of waiting for the next Update call, you can force it with this method

    Returns:

    LTDescr:

    LTDescr an object that distinguishes the tween

    Example:

    LeanTween.moveX(gameObject, 5f, 0f ).updateNow();