You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jan-Ole Schümann edited this page Jun 3, 2017
·
2 revisions
Keyword: onCompleteParams
Defines an object that is passed to the onComplete method when called.
Example: "onCompleteParams", gameObject
This example shows how to chain tweens without using a global reference to the object you want to tween. First, a reference to the GameObject is aquired, which is passed to onTweenComplete1(). The tween from onTweenComplete1() calls onTweenComplete2() with the Reference, which in turn calls onTweenComplete1() and so on. The object will keep moving back and forth forever.
void Start ()
{
GameObject gameObject = GameObject.Find("name_of_gameObject").gameObject;
onTweenComplete1(gameObject);
}
private void onTweenComplete1(object obj)
{
GameObject gameObject = obj as GameObject;
Action<object> onTweenComplete= this.onTweenComplete2;
TweenSharp tween = new TweenSharp(gameObject, 3f, new
{
x = 8f,
onComplete, new Action<object>(onTweenComplete),
onCompleteParams, gameObject
} );
}
private void onTweenComplete2(object obj)
{
GameObject gameObject = obj as GameObject;
TweenSharp tween = new TweenSharp(gameObject, 3f, new
{
x = -8f,
onComplete, onTweenComplete,
onCompleteParams, gameObject
} );
}