From a7fe939981c1d38b1b76ce31b97f6c3b9dc06ac3 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Mon, 21 May 2018 21:39:20 +1000 Subject: [PATCH] Update LeanTween to 2.46 PortraitController forces alpha and color tweens to be non recursive. --- .../Scripts/Components/PortraitController.cs | 12 +- Assets/Fungus/Thirdparty/LeanTween.meta | 6 + Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs | 2285 +++++ .../Thirdparty/LeanTween/LTDescr.cs.meta | 12 + .../Thirdparty/LeanTween/LTDescrOptional.cs | 88 + .../LeanTween/LTDescrOptional.cs.meta | 12 + Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs | 227 + .../Fungus/Thirdparty/LeanTween/LTSeq.cs.meta | 12 + .../Fungus/Thirdparty/LeanTween/LeanAudio.cs | 418 + .../Thirdparty/LeanTween/LeanAudio.cs.meta | 12 + .../Fungus/Thirdparty/LeanTween/LeanTest.cs | 123 + .../Thirdparty/LeanTween/LeanTest.cs.meta | 12 + .../Fungus/Thirdparty/LeanTween/LeanTween.cs | 8358 +++++++---------- .../Thirdparty/LeanTween/LeanTween.cs.meta | 2 +- .../Thirdparty/LeanTween/LeanTween.dll.zip | Bin 0 -> 30942 bytes .../LeanTween/LeanTween.dll.zip.meta | 8 + Assets/Fungus/Thirdparty/LeanTween/ReadMe.txt | 9 - .../Thirdparty/LeanTween/ReadMe.txt.meta | 2 - 18 files changed, 6532 insertions(+), 5066 deletions(-) create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs.meta create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs.meta create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs.meta create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs.meta create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs.meta create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LeanTween.dll.zip create mode 100644 Assets/Fungus/Thirdparty/LeanTween/LeanTween.dll.zip.meta delete mode 100644 Assets/Fungus/Thirdparty/LeanTween/ReadMe.txt delete mode 100644 Assets/Fungus/Thirdparty/LeanTween/ReadMe.txt.meta diff --git a/Assets/Fungus/Scripts/Components/PortraitController.cs b/Assets/Fungus/Scripts/Components/PortraitController.cs index 47c2fc9b..1f58d155 100644 --- a/Assets/Fungus/Scripts/Components/PortraitController.cs +++ b/Assets/Fungus/Scripts/Components/PortraitController.cs @@ -203,7 +203,7 @@ namespace Fungus float duration = (fadeDuration > 0f) ? fadeDuration : float.Epsilon; // Fade in character image (first time) - LeanTween.alpha(portraitImage.transform as RectTransform, 1f, duration).setEase(stage.FadeEaseType); + LeanTween.alpha(portraitImage.transform as RectTransform, 1f, duration).setEase(stage.FadeEaseType).setRecursive(false); // Tell character about portrait image character.State.portraitImage = portraitImage; @@ -455,7 +455,7 @@ namespace Fungus float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon; // Fade out a duplicate of the existing portrait image - if (options.character.State.portraitImage != null) + if (options.character.State.portraitImage != null && options.character.State.portraitImage.sprite != null) { GameObject tempGO = GameObject.Instantiate(options.character.State.portraitImage.gameObject); tempGO.transform.SetParent(options.character.State.portraitImage.transform, false); @@ -469,7 +469,7 @@ namespace Fungus LeanTween.alpha(tempImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType).setOnComplete(() => { Destroy(tempGO); - }); + }).setRecursive(false); } // Fade in the new sprite image @@ -478,7 +478,7 @@ namespace Fungus { options.character.State.portraitImage.sprite = options.portrait; options.character.State.portraitImage.color = new Color(1f, 1f, 1f, 0f); - LeanTween.alpha(options.character.State.portraitImage.rectTransform, 1f, duration).setEase(stage.FadeEaseType); + LeanTween.alpha(options.character.State.portraitImage.rectTransform, 1f, duration).setEase(stage.FadeEaseType).setRecursive(false); } DoMoveTween(options); @@ -577,7 +577,7 @@ namespace Fungus // LeanTween doesn't handle 0 duration properly float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon; - LeanTween.alpha(options.character.State.portraitImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType); + LeanTween.alpha(options.character.State.portraitImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType).setRecursive(false); DoMoveTween(options); @@ -610,7 +610,7 @@ namespace Fungus // LeanTween doesn't handle 0 duration properly float duration = (stage.FadeDuration > 0f) ? stage.FadeDuration : float.Epsilon; - LeanTween.color(character.State.portraitImage.rectTransform, targetColor, duration).setEase(stage.FadeEaseType); + LeanTween.color(character.State.portraitImage.rectTransform, targetColor, duration).setEase(stage.FadeEaseType).setRecursive(false); } #endregion diff --git a/Assets/Fungus/Thirdparty/LeanTween.meta b/Assets/Fungus/Thirdparty/LeanTween.meta index 0bc313d3..eb22f9ca 100644 --- a/Assets/Fungus/Thirdparty/LeanTween.meta +++ b/Assets/Fungus/Thirdparty/LeanTween.meta @@ -1,2 +1,8 @@ fileFormatVersion: 2 guid: 5e6a0fa47acf54892bbdae89028eaec3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs b/Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs new file mode 100644 index 00000000..aed6fb65 --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs @@ -0,0 +1,2285 @@ +//namespace DentedPixel{ +using System; +using UnityEngine; + +/** +* 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);
+*   }
+* @class LTDescr +* @constructor +*/ +public class LTDescr +{ + public bool toggle; + public bool useEstimatedTime; + public bool useFrames; + public bool useManualTime; + public bool usesNormalDt; + public bool hasInitiliazed; + public bool hasExtraOnCompletes; + public bool hasPhysics; + public bool onCompleteOnRepeat; + public bool onCompleteOnStart; + public bool useRecursion; + public float ratioPassed; + public float passed; + public float delay; + public float time; + public float speed; + public float lastVal; + private uint _id; + public int loopCount; + public uint counter = uint.MaxValue; + public float direction; + public float directionLast; + public float overshoot; + public float period; + public float scale; + public bool destroyOnComplete; + public Transform trans; + internal Vector3 fromInternal; + public Vector3 from { get { return this.fromInternal; } set { this.fromInternal = value; } } + internal Vector3 toInternal; + public Vector3 to { get { return this.toInternal; } set { this.toInternal = value; } } + internal Vector3 diff; + internal Vector3 diffDiv2; + public TweenAction type; + private LeanTweenType easeType; + public LeanTweenType loopType; + + public bool hasUpdateCallback; + + public EaseTypeDelegate easeMethod; + public ActionMethodDelegate easeInternal {get; set; } + public ActionMethodDelegate initInternal {get; set; } + public delegate Vector3 EaseTypeDelegate(); + public delegate void ActionMethodDelegate(); + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + public SpriteRenderer spriteRen; + #endif + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + public RectTransform rectTransform; + public UnityEngine.UI.Text uiText; + public UnityEngine.UI.Image uiImage; + public UnityEngine.UI.RawImage rawImage; + public UnityEngine.Sprite[] sprites; + #endif + + public LTDescrOptional _optional = new LTDescrOptional(); + + public override string ToString(){ + return (trans!=null ? "name:"+trans.gameObject.name : "gameObject:null")+" toggle:"+toggle+" passed:"+passed+" time:"+time+" delay:"+delay+" direction:"+direction+" from:"+from+" to:"+to+" diff:"+diff+" type:"+type+" ease:"+easeType+" useEstimatedTime:"+useEstimatedTime+" id:"+id+" hasInitiliazed:"+hasInitiliazed; + } + + public LTDescr(){ + + } + + [System.Obsolete("Use 'LeanTween.cancel( id )' instead")] + public LTDescr cancel( GameObject gameObject ){ + // Debug.Log("canceling id:"+this._id+" this.uniqueId:"+this.uniqueId+" go:"+this.trans.gameObject); + if(gameObject==this.trans.gameObject) + LeanTween.removeTween((int)this._id, this.uniqueId); + return this; + } + + public int uniqueId{ + get{ + uint toId = _id | counter << 16; + + /*uint backId = toId & 0xFFFF; + uint backCounter = toId >> 16; + if(_id!=backId || backCounter!=counter){ + Debug.LogError("BAD CONVERSION toId:"+_id); + }*/ + + return (int)toId; + } + } + + public int id{ + get{ + return uniqueId; + } + } + + public LTDescrOptional optional{ + get{ + return _optional; + } + set{ + this._optional = optional; + } + } + + public void reset(){ + this.toggle = this.useRecursion = this.usesNormalDt = true; + this.trans = null; + this.spriteRen = null; + this.passed = this.delay = this.lastVal = 0.0f; + this.hasUpdateCallback = this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = this.onCompleteOnStart = this.useManualTime = this.hasExtraOnCompletes = false; + this.easeType = LeanTweenType.linear; + this.loopType = LeanTweenType.once; + this.loopCount = 0; + this.direction = this.directionLast = this.overshoot = this.scale = 1.0f; + this.period = 0.3f; + this.speed = -1f; + this.easeMethod = this.easeLinear; + this.from = this.to = Vector3.zero; + this._optional.reset(); + + + } + + // Initialize and Internal Methods + + public LTDescr setMoveX(){ + this.type = TweenAction.MOVE_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.position.x; }; + this.easeInternal = ()=>{ trans.position=new Vector3( easeMethod().x,trans.position.y,trans.position.z); }; + return this; + } + + public LTDescr setMoveY(){ + this.type = TweenAction.MOVE_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.position.y; }; + this.easeInternal = ()=>{ trans.position=new Vector3( trans.position.x,easeMethod().x,trans.position.z); }; + return this; + } + + public LTDescr setMoveZ(){ + this.type = TweenAction.MOVE_Z; + this.initInternal = ()=>{ this.fromInternal.x = trans.position.z; };; + this.easeInternal = ()=>{ trans.position=new Vector3( trans.position.x,trans.position.y,easeMethod().x); }; + return this; + } + + public LTDescr setMoveLocalX(){ + this.type = TweenAction.MOVE_LOCAL_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.localPosition.x; }; + this.easeInternal = ()=>{ trans.localPosition=new Vector3( easeMethod().x,trans.localPosition.y,trans.localPosition.z); }; + return this; + } + + public LTDescr setMoveLocalY(){ + this.type = TweenAction.MOVE_LOCAL_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.localPosition.y; }; + this.easeInternal = ()=>{ trans.localPosition=new Vector3( trans.localPosition.x,easeMethod().x,trans.localPosition.z); }; + return this; + } + + public LTDescr setMoveLocalZ(){ + this.type = TweenAction.MOVE_LOCAL_Z; + this.initInternal = ()=>{ this.fromInternal.x = trans.localPosition.z; }; + this.easeInternal = ()=>{ trans.localPosition=new Vector3( trans.localPosition.x,trans.localPosition.y,easeMethod().x); }; + return this; + } + + private void initFromInternal(){ this.fromInternal.x = 0; } + + public LTDescr setMoveCurved(){ + this.type = TweenAction.MOVE_CURVED; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.path.orientToPath){ + if(this._optional.path.orientToPath2d){ + this._optional.path.place2d( trans, val ); + }else{ + this._optional.path.place( trans, val ); + } + }else{ + trans.position = this._optional.path.point( val ); + } + }; + return this; + } + + public LTDescr setMoveCurvedLocal(){ + this.type = TweenAction.MOVE_CURVED_LOCAL; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.path.orientToPath){ + if(this._optional.path.orientToPath2d){ + this._optional.path.placeLocal2d( trans, val ); + }else{ + this._optional.path.placeLocal( trans, val ); + } + }else{ + trans.localPosition = this._optional.path.point( val ); + } + }; + return this; + } + + public LTDescr setMoveSpline(){ + this.type = TweenAction.MOVE_SPLINE; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.spline.orientToPath){ + if(this._optional.spline.orientToPath2d){ + this._optional.spline.place2d( trans, val ); + }else{ + this._optional.spline.place( trans, val ); + } + }else{ + trans.position = this._optional.spline.point( val ); + } + }; + return this; + } + + public LTDescr setMoveSplineLocal(){ + this.type = TweenAction.MOVE_SPLINE_LOCAL; + this.initInternal = this.initFromInternal; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this._optional.spline.orientToPath){ + if(this._optional.spline.orientToPath2d){ + this._optional.spline.placeLocal2d( trans, val ); + }else{ + this._optional.spline.placeLocal( trans, val ); + } + }else{ + trans.localPosition = this._optional.spline.point( val ); + } + }; + return this; + } + + public LTDescr setScaleX(){ + this.type = TweenAction.SCALE_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.x; }; + this.easeInternal = ()=>{ trans.localScale = new Vector3( easeMethod().x,trans.localScale.y,trans.localScale.z); }; + return this; + } + + public LTDescr setScaleY(){ + this.type = TweenAction.SCALE_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.y; }; + this.easeInternal = ()=>{ trans.localScale=new Vector3( trans.localScale.x,easeMethod().x,trans.localScale.z); }; + return this; + } + + public LTDescr setScaleZ(){ + this.type = TweenAction.SCALE_Z; + this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.z; }; + this.easeInternal = ()=>{ trans.localScale=new Vector3( trans.localScale.x,trans.localScale.y,easeMethod().x); }; + return this; + } + + public LTDescr setRotateX(){ + this.type = TweenAction.ROTATE_X; + this.initInternal = ()=>{ this.fromInternal.x = trans.eulerAngles.x; this.toInternal.x = LeanTween.closestRot( this.fromInternal.x, this.toInternal.x);}; + this.easeInternal = ()=>{ trans.eulerAngles=new Vector3(easeMethod().x,trans.eulerAngles.y,trans.eulerAngles.z); }; + return this; + } + + public LTDescr setRotateY(){ + this.type = TweenAction.ROTATE_Y; + this.initInternal = ()=>{ this.fromInternal.x = trans.eulerAngles.y; this.toInternal.x = LeanTween.closestRot( this.fromInternal.x, this.toInternal.x);}; + this.easeInternal = ()=>{ trans.eulerAngles=new Vector3(trans.eulerAngles.x,easeMethod().x,trans.eulerAngles.z); }; + return this; + } + + public LTDescr setRotateZ(){ + this.type = TweenAction.ROTATE_Z; + this.initInternal = ()=>{ + this.fromInternal.x = trans.eulerAngles.z; + this.toInternal.x = LeanTween.closestRot( this.fromInternal.x, this.toInternal.x); + }; + this.easeInternal = ()=>{ trans.eulerAngles=new Vector3(trans.eulerAngles.x,trans.eulerAngles.y,easeMethod().x); }; + return this; + } + + public LTDescr setRotateAround(){ + this.type = TweenAction.ROTATE_AROUND; + this.initInternal = ()=>{ + this.fromInternal.x = 0f; + this._optional.origRotation = trans.rotation; + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Vector3 origPos = trans.localPosition; + Vector3 rotateAroundPt = (Vector3)trans.TransformPoint( this._optional.point ); + // Debug.Log("this._optional.point:"+this._optional.point); + trans.RotateAround(rotateAroundPt, this._optional.axis, -this._optional.lastVal); + Vector3 diff = origPos - trans.localPosition; + + trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + trans.rotation = this._optional.origRotation; + + rotateAroundPt = (Vector3)trans.TransformPoint( this._optional.point ); + trans.RotateAround(rotateAroundPt, this._optional.axis, val); + + this._optional.lastVal = val; + }; + return this; + } + + public LTDescr setRotateAroundLocal(){ + this.type = TweenAction.ROTATE_AROUND_LOCAL; + this.initInternal = ()=>{ + this.fromInternal.x = 0f; + this._optional.origRotation = trans.localRotation; + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Vector3 origPos = trans.localPosition; + trans.RotateAround((Vector3)trans.TransformPoint( this._optional.point ), trans.TransformDirection(this._optional.axis), -this._optional.lastVal); + Vector3 diff = origPos - trans.localPosition; + + trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + trans.localRotation = this._optional.origRotation; + Vector3 rotateAroundPt = (Vector3)trans.TransformPoint( this._optional.point ); + trans.RotateAround(rotateAroundPt, trans.TransformDirection(this._optional.axis), val); + + this._optional.lastVal = val; + }; + return this; + } + + public LTDescr setAlpha(){ + this.type = TweenAction.ALPHA; + this.initInternal = ()=>{ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + if(trans.gameObject.renderer){ this.fromInternal.x = trans.gameObject.renderer.material.color.a; }else if(trans.childCount>0){ foreach (Transform child in trans) { if(child.gameObject.renderer!=null){ Color col = child.gameObject.renderer.material.color; this.fromInternal.x = col.a; break; }}} + this.easeInternal = this.alpha; + break; + #else + SpriteRenderer ren = trans.GetComponent(); + if(ren!=null){ + this.fromInternal.x = ren.color.a; + }else{ + if(trans.GetComponent()!=null && trans.GetComponent().material.HasProperty("_Color")){ + this.fromInternal.x = trans.GetComponent().material.color.a; + }else if(trans.GetComponent()!=null && trans.GetComponent().material.HasProperty("_TintColor")){ + Color col = trans.GetComponent().material.GetColor("_TintColor"); + this.fromInternal.x = col.a; + }else if(trans.childCount>0){ + foreach (Transform child in trans) { + if(child.gameObject.GetComponent()!=null){ + Color col = child.gameObject.GetComponent().material.color; + this.fromInternal.x = col.a; + break; + } + } + } + } + #endif + + this.easeInternal = ()=>{ + val = easeMethod().x; + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + alphaRecursive(this.trans, val, this.useRecursion); + #else + if(this.spriteRen!=null){ + this.spriteRen.color = new Color( this.spriteRen.color.r, this.spriteRen.color.g, this.spriteRen.color.b, val); + alphaRecursiveSprite(this.trans, val); + }else{ + alphaRecursive(this.trans, val, this.useRecursion); + } + #endif + }; + + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + alphaRecursive(this.trans, val, this.useRecursion); + #else + if(this.spriteRen!=null){ + this.spriteRen.color = new Color( this.spriteRen.color.r, this.spriteRen.color.g, this.spriteRen.color.b, val); + alphaRecursiveSprite(this.trans, val); + }else{ + alphaRecursive(this.trans, val, this.useRecursion); + } + #endif + }; + return this; + } + + public LTDescr setTextAlpha(){ + this.type = TweenAction.TEXT_ALPHA; + this.initInternal = ()=>{ + this.uiText = trans.GetComponent(); + this.fromInternal.x = this.uiText != null ? this.uiText.color.a : 1f; + }; + this.easeInternal = ()=>{ textAlphaRecursive( trans, easeMethod().x, this.useRecursion ); }; + return this; + } + + public LTDescr setAlphaVertex(){ + this.type = TweenAction.ALPHA_VERTEX; + this.initInternal = ()=>{ this.fromInternal.x = trans.GetComponent().mesh.colors32[0].a; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Mesh mesh = trans.GetComponent().mesh; + Vector3[] vertices = mesh.vertices; + Color32[] colors = new Color32[vertices.Length]; + if (colors.Length == 0){ //MaxFW fix: add vertex colors if the mesh doesn't have any + Color32 transparentWhiteColor32 = new Color32(0xff, 0xff, 0xff, 0x00); + colors = new Color32[mesh.vertices.Length]; + for (int k=0; k{ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + if(trans.gameObject.renderer){ + this.setFromColor( trans.gameObject.renderer.material.color ); + }else if(trans.childCount>0){ + foreach (Transform child in trans) { + if(child.gameObject.renderer!=null){ + this.setFromColor( child.gameObject.renderer.material.color ); + break; + } + } + } + #else + SpriteRenderer renColor = trans.GetComponent(); + if(renColor!=null){ + this.setFromColor( renColor.color ); + }else{ + if(trans.GetComponent()!=null && trans.GetComponent().material.HasProperty("_Color")){ + Color col = trans.GetComponent().material.color; + this.setFromColor( col ); + }else if(trans.GetComponent()!=null && trans.GetComponent().material.HasProperty("_TintColor")){ + Color col = trans.GetComponent().material.GetColor ("_TintColor"); + this.setFromColor( col ); + }else if(trans.childCount>0){ + foreach (Transform child in trans) { + if(child.gameObject.GetComponent()!=null){ + Color col = child.gameObject.GetComponent().material.color; + this.setFromColor( col ); + break; + } + } + } + } + #endif + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + + if(this.spriteRen!=null){ + this.spriteRen.color = toColor; + colorRecursiveSprite( trans, toColor); + }else{ + #endif + // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff); + if(this.type==TweenAction.COLOR) + colorRecursive(trans, toColor, this.useRecursion); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + } + #endif + if(dt!=0f && this._optional.onUpdateColor!=null){ + this._optional.onUpdateColor(toColor); + }else if(dt!=0f && this._optional.onUpdateColorObject!=null){ + this._optional.onUpdateColorObject(toColor, this._optional.onUpdateParam); + } + }; + return this; + } + + public LTDescr setCallbackColor(){ + this.type = TweenAction.CALLBACK_COLOR; + this.initInternal = ()=>{ this.diff = new Vector3(1.0f,0.0f,0.0f); }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + if(this.spriteRen!=null){ + this.spriteRen.color = toColor; + colorRecursiveSprite( trans, toColor); + }else{ + #endif + // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff); + if(this.type==TweenAction.COLOR) + colorRecursive(trans, toColor, this.useRecursion); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + } + #endif + if(dt!=0f && this._optional.onUpdateColor!=null){ + this._optional.onUpdateColor(toColor); + }else if(dt!=0f && this._optional.onUpdateColorObject!=null){ + this._optional.onUpdateColorObject(toColor, this._optional.onUpdateParam); + } + }; + return this; + } + + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + public LTDescr setTextColor(){ + this.type = TweenAction.TEXT_COLOR; + this.initInternal = ()=>{ + this.uiText = trans.GetComponent(); + this.setFromColor( this.uiText != null ? this.uiText.color : Color.white ); + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + this.uiText.color = toColor; + if (dt!=0f && this._optional.onUpdateColor != null) + this._optional.onUpdateColor(toColor); + + if(this.useRecursion && trans.childCount>0) + textColorRecursive(this.trans, toColor); + }; + return this; + } + + public LTDescr setCanvasAlpha(){ + this.type = TweenAction.CANVAS_ALPHA; + this.initInternal = ()=>{ + this.uiImage = trans.GetComponent(); + if(this.uiImage!=null){ + this.fromInternal.x = this.uiImage.color.a; + }else{ + this.rawImage = trans.GetComponent(); + if(this.rawImage != null){ + this.fromInternal.x = this.rawImage.color.a; + }else{ + this.fromInternal.x = 1f; + } + } + + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + if(this.uiImage!=null){ + Color c = this.uiImage.color; c.a = val; this.uiImage.color = c; + }else if(this.rawImage!=null){ + Color c = this.rawImage.color; c.a = val; this.rawImage.color = c; + } + if(this.useRecursion){ + alphaRecursive( this.rectTransform, val, 0 ); + textAlphaChildrenRecursive( this.rectTransform, val); + } + }; + return this; + } + + public LTDescr setCanvasGroupAlpha(){ + this.type = TweenAction.CANVASGROUP_ALPHA; + this.initInternal = ()=>{this.fromInternal.x = trans.GetComponent().alpha;}; + this.easeInternal = ()=>{ this.trans.GetComponent().alpha = easeMethod().x; }; + return this; + } + + public LTDescr setCanvasColor(){ + this.type = TweenAction.CANVAS_COLOR; + this.initInternal = ()=>{ + this.uiImage = trans.GetComponent(); + if(this.uiImage==null){ + this.rawImage = trans.GetComponent(); + this.setFromColor( this.rawImage!=null ? this.rawImage.color : Color.white ); + }else{ + this.setFromColor( this.uiImage.color ); + } + + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + Color toColor = tweenColor(this, val); + if(this.uiImage!=null){ + this.uiImage.color = toColor; + }else if(this.rawImage!=null){ + this.rawImage.color = toColor; + } + + if (dt!=0f && this._optional.onUpdateColor != null) + this._optional.onUpdateColor(toColor); + + if(this.useRecursion) + colorRecursive(this.rectTransform, toColor); + }; + return this; + } + + public LTDescr setCanvasMoveX(){ + this.type = TweenAction.CANVAS_MOVE_X; + this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.x; }; + this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(easeMethod().x, c.y, c.z); }; + return this; + } + + public LTDescr setCanvasMoveY(){ + this.type = TweenAction.CANVAS_MOVE_Y; + this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.y; }; + this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(c.x, easeMethod().x, c.z); }; + return this; + } + + public LTDescr setCanvasMoveZ(){ + this.type = TweenAction.CANVAS_MOVE_Z; + this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.z; }; + this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(c.x, c.y, easeMethod().x); }; + return this; + } + + private void initCanvasRotateAround(){ + this.lastVal = 0.0f; + this.fromInternal.x = 0.0f; + this._optional.origRotation = this.rectTransform.rotation; + } + + public LTDescr setCanvasRotateAround(){ + this.type = TweenAction.CANVAS_ROTATEAROUND; + this.initInternal = this.initCanvasRotateAround; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + RectTransform rect = this.rectTransform; + Vector3 origPos = rect.localPosition; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), this._optional.axis, -val); + Vector3 diff = origPos - rect.localPosition; + + rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + rect.rotation = this._optional.origRotation; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), this._optional.axis, val); + }; + return this; + } + + public LTDescr setCanvasRotateAroundLocal(){ + this.type = TweenAction.CANVAS_ROTATEAROUND_LOCAL; + this.initInternal = this.initCanvasRotateAround; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + RectTransform rect = this.rectTransform; + Vector3 origPos = rect.localPosition; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), rect.TransformDirection(this._optional.axis), -val); + Vector3 diff = origPos - rect.localPosition; + + rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position + rect.rotation = this._optional.origRotation; + rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), rect.TransformDirection(this._optional.axis), val); + }; + return this; + } + + public LTDescr setCanvasPlaySprite(){ + this.type = TweenAction.CANVAS_PLAYSPRITE; + this.initInternal = ()=>{ + this.uiImage = trans.GetComponent(); + this.fromInternal.x = 0f; + }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + val = newVect.x; + int frame = (int)Mathf.Round( val ); + this.uiImage.sprite = this.sprites[ frame ]; + }; + return this; + } + + public LTDescr setCanvasMove(){ + this.type = TweenAction.CANVAS_MOVE; + this.initInternal = ()=>{ this.fromInternal = this.rectTransform.anchoredPosition3D; }; + this.easeInternal = ()=>{ this.rectTransform.anchoredPosition3D = easeMethod(); }; + return this; + } + + public LTDescr setCanvasScale(){ + this.type = TweenAction.CANVAS_SCALE; + this.initInternal = ()=>{ this.from = this.rectTransform.localScale; }; + this.easeInternal = ()=>{ this.rectTransform.localScale = easeMethod(); }; + return this; + } + + public LTDescr setCanvasSizeDelta(){ + this.type = TweenAction.CANVAS_SIZEDELTA; + this.initInternal = ()=>{ this.from = this.rectTransform.sizeDelta; }; + this.easeInternal = ()=>{ this.rectTransform.sizeDelta = easeMethod(); }; + return this; + } + #endif + + private void callback(){ newVect = easeMethod(); val = newVect.x; } + + public LTDescr setCallback(){ + this.type = TweenAction.CALLBACK; + this.initInternal = ()=>{}; + this.easeInternal = this.callback; + return this; + } + public LTDescr setValue3(){ + this.type = TweenAction.VALUE3; + this.initInternal = ()=>{}; + this.easeInternal = this.callback; + return this; + } + + public LTDescr setMove(){ + this.type = TweenAction.MOVE; + this.initInternal = ()=>{ this.from = trans.position; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.position = newVect; + }; + return this; + } + + public LTDescr setMoveLocal(){ + this.type = TweenAction.MOVE_LOCAL; + this.initInternal = ()=>{ this.from = trans.localPosition; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.localPosition = newVect; + }; + return this; + } + + public LTDescr setMoveToTransform(){ + this.type = TweenAction.MOVE_TO_TRANSFORM; + this.initInternal = ()=>{ this.from = trans.position; }; + this.easeInternal = ()=>{ + this.to = this._optional.toTrans.position; + this.diff = this.to - this.from; + this.diffDiv2 = this.diff * 0.5f; + + newVect = easeMethod(); + this.trans.position = newVect; + }; + return this; + } + + public LTDescr setRotate(){ + this.type = TweenAction.ROTATE; + this.initInternal = ()=>{ this.from = trans.eulerAngles; this.to = new Vector3(LeanTween.closestRot( this.fromInternal.x, this.toInternal.x), LeanTween.closestRot( this.from.y, this.to.y), LeanTween.closestRot( this.from.z, this.to.z)); }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.eulerAngles = newVect; + }; + return this; + } + + public LTDescr setRotateLocal(){ + this.type = TweenAction.ROTATE_LOCAL; + this.initInternal = ()=>{ this.from = trans.localEulerAngles; this.to = new Vector3(LeanTween.closestRot( this.fromInternal.x, this.toInternal.x), LeanTween.closestRot( this.from.y, this.to.y), LeanTween.closestRot( this.from.z, this.to.z)); }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.localEulerAngles = newVect; + }; + return this; + } + + public LTDescr setScale(){ + this.type = TweenAction.SCALE; + this.initInternal = ()=>{ this.from = trans.localScale; }; + this.easeInternal = ()=>{ + newVect = easeMethod(); + trans.localScale = newVect; + }; + return this; + } + + public LTDescr setGUIMove(){ + this.type = TweenAction.GUI_MOVE; + this.initInternal = ()=>{ this.from = new Vector3(this._optional.ltRect.rect.x, this._optional.ltRect.rect.y, 0); }; + this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.rect = new Rect( v.x, v.y, this._optional.ltRect.rect.width, this._optional.ltRect.rect.height); }; + return this; + } + + public LTDescr setGUIMoveMargin(){ + this.type = TweenAction.GUI_MOVE_MARGIN; + this.initInternal = ()=>{ this.from = new Vector2(this._optional.ltRect.margin.x, this._optional.ltRect.margin.y); }; + this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.margin = new Vector2(v.x, v.y); }; + return this; + } + + public LTDescr setGUIScale(){ + this.type = TweenAction.GUI_SCALE; + this.initInternal = ()=>{ this.from = new Vector3(this._optional.ltRect.rect.width, this._optional.ltRect.rect.height, 0); }; + this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.rect = new Rect( this._optional.ltRect.rect.x, this._optional.ltRect.rect.y, v.x, v.y); }; + return this; + } + + public LTDescr setGUIAlpha(){ + this.type = TweenAction.GUI_ALPHA; + this.initInternal = ()=>{ this.fromInternal.x = this._optional.ltRect.alpha; }; + this.easeInternal = ()=>{ this._optional.ltRect.alpha = easeMethod().x; }; + return this; + } + + public LTDescr setGUIRotate(){ + this.type = TweenAction.GUI_ROTATE; + this.initInternal = ()=>{ if(this._optional.ltRect.rotateEnabled==false){ + this._optional.ltRect.rotateEnabled = true; + this._optional.ltRect.resetForRotation(); + } + + this.fromInternal.x = this._optional.ltRect.rotation; + }; + this.easeInternal = ()=>{ this._optional.ltRect.rotation = easeMethod().x; }; + return this; + } + + public LTDescr setDelayedSound(){ + this.type = TweenAction.DELAYED_SOUND; + this.initInternal = ()=>{ this.hasExtraOnCompletes = true; }; + this.easeInternal = this.callback; + return this; + } + + private void init(){ + this.hasInitiliazed = true; + + usesNormalDt = !(useEstimatedTime || useManualTime || useFrames); // only set this to true if it uses non of the other timing modes + + if (useFrames) + this.optional.initFrameCount = Time.frameCount; + + if (this.time <= 0f) // avoid dividing by zero + this.time = Mathf.Epsilon; + + this.initInternal(); + + this.diff = this.to - this.from; + this.diffDiv2 = this.diff * 0.5f; + + if (this._optional.onStart != null) + this._optional.onStart(); + + if(this.onCompleteOnStart) + callOnCompletes(); + + if(this.speed>=0){ + initSpeed(); + } + } + + private void initSpeed(){ + if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ + this.time = this._optional.path.distance / this.speed; + }else if(this.type==TweenAction.MOVE_SPLINE || this.type==TweenAction.MOVE_SPLINE_LOCAL){ + this.time = this._optional.spline.distance/ this.speed; + }else{ + this.time = (this.to - this.from).magnitude / this.speed; + } + } + + public static float val; + public static float dt; + public static Vector3 newVect; + + /** + * If you need a tween to happen immediately instead of waiting for the next Update call, you can force it with this method + * + * @method updateNow + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 0f ).updateNow(); + */ + public LTDescr updateNow(){ + updateInternal(); + return this; + } + + public bool updateInternal(){ + + float directionLocal = this.direction; + if(this.usesNormalDt){ + dt = LeanTween.dtActual; + }else if( this.useEstimatedTime ){ + dt = LeanTween.dtEstimated; + }else if( this.useFrames ){ + dt = this.optional.initFrameCount==0 ? 0 : 1; + this.optional.initFrameCount = Time.frameCount; + }else if( this.useManualTime ){ + dt = LeanTween.dtManual; + } + +// Debug.Log ("tween:" + this+ " dt:"+dt); + if(this.delay<=0f && directionLocal!=0f){ + if(trans==null) + return true; + + // initialize if has not done so yet + if(!this.hasInitiliazed) + this.init(); + + dt = dt*directionLocal; + this.passed += dt; + + this.passed = Mathf.Clamp(this.passed, 0f, this.time); + + this.ratioPassed = (this.passed / this.time); // need to clamp when finished so it will finish at the exact spot and not overshoot + + this.easeInternal(); + + if(this.hasUpdateCallback) + this._optional.callOnUpdate(val, this.ratioPassed); + + bool isTweenFinished = directionLocal>0f ? this.passed>=this.time : this.passed<=0f; + // Debug.Log("lt "+this+" dt:"+dt+" fin:"+isTweenFinished); + if(isTweenFinished){ // increment or flip tween + this.loopCount--; + if(this.loopType==LeanTweenType.pingPong){ + this.direction = 0.0f-directionLocal; + }else{ + this.passed = Mathf.Epsilon; + } + + isTweenFinished = this.loopCount == 0 || this.loopType == LeanTweenType.once; // only return true if it is fully complete + + if(isTweenFinished==false && this.onCompleteOnRepeat && this.hasExtraOnCompletes) + callOnCompletes(); // this only gets called if onCompleteOnRepeat is set to true, otherwise LeanTween class takes care of calling it + + return isTweenFinished; + } + }else{ + this.delay -= dt; + } + + return false; + } + + public void callOnCompletes(){ + if(this.type==TweenAction.GUI_ROTATE) + this._optional.ltRect.rotateFinished = true; + + if(this.type==TweenAction.DELAYED_SOUND){ + AudioSource.PlayClipAtPoint((AudioClip)this._optional.onCompleteParam, this.to, this.from.x); + } + if(this._optional.onComplete!=null){ + this._optional.onComplete(); + }else if(this._optional.onCompleteObject!=null){ + this._optional.onCompleteObject(this._optional.onCompleteParam); + } + } + + // Helper Methods + + public LTDescr setFromColor( Color col ){ + this.from = new Vector3(0.0f, col.a, 0.0f); + this.diff = new Vector3(1.0f,0.0f,0.0f); + this._optional.axis = new Vector3( col.r, col.g, col.b ); + return this; + } + + private static void alphaRecursive( Transform transform, float val, bool useRecursion = true){ + Renderer renderer = transform.gameObject.GetComponent(); + if(renderer!=null){ + foreach(Material mat in renderer.materials){ + if(mat.HasProperty("_Color")){ + mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val); + }else if(mat.HasProperty("_TintColor")){ + Color col = mat.GetColor ("_TintColor"); + mat.SetColor("_TintColor", new Color( col.r, col.g, col.b, val)); + } + } + } + if(useRecursion && transform.childCount>0){ + foreach (Transform child in transform) { + alphaRecursive(child, val); + } + } + } + + private static void colorRecursive( Transform transform, Color toColor, bool useRecursion = true ){ + Renderer ren = transform.gameObject.GetComponent(); + if(ren!=null){ + foreach(Material mat in ren.materials){ + mat.color = toColor; + } + } + if(useRecursion && transform.childCount>0){ + foreach (Transform child in transform) { + colorRecursive(child, toColor); + } + } + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + + private static void alphaRecursive( RectTransform rectTransform, float val, int recursiveLevel = 0){ + if(rectTransform.childCount>0){ + foreach (RectTransform child in rectTransform) { + UnityEngine.UI.MaskableGraphic uiImage = child.GetComponent(); + if (uiImage != null) { + Color c = uiImage.color; c.a = val; uiImage.color = c; + } else { + uiImage = child.GetComponent(); + if (uiImage != null) { + Color c = uiImage.color; c.a = val; uiImage.color = c; + } + } + + alphaRecursive(child, val, recursiveLevel + 1); + } + } + } + + private static void alphaRecursiveSprite( Transform transform, float val ){ + if(transform.childCount>0){ + foreach (Transform child in transform) { + SpriteRenderer ren = child.GetComponent(); + if(ren!=null) + ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val); + alphaRecursiveSprite(child, val); + } + } + } + + private static void colorRecursiveSprite( Transform transform, Color toColor ){ + if(transform.childCount>0){ + foreach (Transform child in transform) { + SpriteRenderer ren = transform.gameObject.GetComponent(); + if(ren!=null) + ren.color = toColor; + colorRecursiveSprite(child, toColor); + } + } + } + + private static void colorRecursive( RectTransform rectTransform, Color toColor ){ + + if(rectTransform.childCount>0){ + foreach (RectTransform child in rectTransform) { + UnityEngine.UI.MaskableGraphic uiImage = child.GetComponent(); + if (uiImage != null) { + uiImage.color = toColor; + } else { + uiImage = child.GetComponent(); + if (uiImage != null) + uiImage.color = toColor; + } + colorRecursive(child, toColor); + } + } + } + + private static void textAlphaChildrenRecursive( Transform trans, float val, bool useRecursion = true ){ + + if(useRecursion && trans.childCount>0){ + foreach (Transform child in trans) { + UnityEngine.UI.Text uiText = child.GetComponent(); + if(uiText!=null){ + Color c = uiText.color; + c.a = val; + uiText.color = c; + } + textAlphaChildrenRecursive(child, val); + } + } + } + + private static void textAlphaRecursive( Transform trans, float val, bool useRecursion = true ){ + UnityEngine.UI.Text uiText = trans.GetComponent(); + if(uiText!=null){ + Color c = uiText.color; + c.a = val; + uiText.color = c; + } + if(useRecursion && trans.childCount>0){ + foreach (Transform child in trans) { + textAlphaRecursive(child, val); + } + } + } + + private static void textColorRecursive(Transform trans, Color toColor ){ + if(trans.childCount>0){ + foreach (Transform child in trans) { + UnityEngine.UI.Text uiText = child.GetComponent(); + if(uiText!=null){ + uiText.color = toColor; + } + textColorRecursive(child, toColor); + } + } + } + #endif + + private static Color tweenColor( LTDescr tween, float val ){ + Vector3 diff3 = tween._optional.point - tween._optional.axis; + float diffAlpha = tween.to.y - tween.from.y; + return new Color(tween._optional.axis.x + diff3.x*val, tween._optional.axis.y + diff3.y*val, tween._optional.axis.z + diff3.z*val, tween.from.y + diffAlpha*val); + } + + /** + * Pause a tween + * + * @method pause + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public LTDescr pause(){ + if(this.direction != 0.0f){ // check if tween is already paused + this.directionLast = this.direction; + this.direction = 0.0f; + } + + return this; + } + + /** + * Resume a paused tween + * + * @method resume + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public LTDescr resume(){ + this.direction = this.directionLast; + + return this; + } + + /** + * Set Axis optional axis for tweens where it is relevant + * + * @method setAxis + * @param {Vector3} axis either the tween rotates around, or the direction it faces in the case of setOrientToPath + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward); + */ + public LTDescr setAxis( Vector3 axis ){ + this._optional.axis = axis; + return this; + } + + /** + * Delay the start of a tween + * + * @method setDelay + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setDelay( 1.5f ); + */ + public LTDescr setDelay( float delay ){ + this.delay = delay; + + return this; + } + + /** + * Set the type of easing used for the tween.
+ * + * + * @method setEase + * @param {LeanTweenType} easeType:LeanTweenType the easing type to use + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); + */ + public LTDescr setEase( LeanTweenType easeType ){ + + switch( easeType ){ + case LeanTweenType.linear: + setEaseLinear(); break; + case LeanTweenType.easeOutQuad: + setEaseOutQuad(); break; + case LeanTweenType.easeInQuad: + setEaseInQuad(); break; + case LeanTweenType.easeInOutQuad: + setEaseInOutQuad(); break; + case LeanTweenType.easeInCubic: + setEaseInCubic();break; + case LeanTweenType.easeOutCubic: + setEaseOutCubic(); break; + case LeanTweenType.easeInOutCubic: + setEaseInOutCubic(); break; + case LeanTweenType.easeInQuart: + setEaseInQuart(); break; + case LeanTweenType.easeOutQuart: + setEaseOutQuart(); break; + case LeanTweenType.easeInOutQuart: + setEaseInOutQuart(); break; + case LeanTweenType.easeInQuint: + setEaseInQuint(); break; + case LeanTweenType.easeOutQuint: + setEaseOutQuint(); break; + case LeanTweenType.easeInOutQuint: + setEaseInOutQuint(); break; + case LeanTweenType.easeInSine: + setEaseInSine(); break; + case LeanTweenType.easeOutSine: + setEaseOutSine(); break; + case LeanTweenType.easeInOutSine: + setEaseInOutSine(); break; + case LeanTweenType.easeInExpo: + setEaseInExpo(); break; + case LeanTweenType.easeOutExpo: + setEaseOutExpo(); break; + case LeanTweenType.easeInOutExpo: + setEaseInOutExpo(); break; + case LeanTweenType.easeInCirc: + setEaseInCirc(); break; + case LeanTweenType.easeOutCirc: + setEaseOutCirc(); break; + case LeanTweenType.easeInOutCirc: + setEaseInOutCirc(); break; + case LeanTweenType.easeInBounce: + setEaseInBounce(); break; + case LeanTweenType.easeOutBounce: + setEaseOutBounce(); break; + case LeanTweenType.easeInOutBounce: + setEaseInOutBounce(); break; + case LeanTweenType.easeInBack: + setEaseInBack(); break; + case LeanTweenType.easeOutBack: + setEaseOutBack(); break; + case LeanTweenType.easeInOutBack: + setEaseInOutBack(); break; + case LeanTweenType.easeInElastic: + setEaseInElastic(); break; + case LeanTweenType.easeOutElastic: + setEaseOutElastic(); break; + case LeanTweenType.easeInOutElastic: + setEaseInOutElastic(); break; + case LeanTweenType.punch: + setEasePunch(); break; + case LeanTweenType.easeShake: + setEaseShake(); break; + case LeanTweenType.easeSpring: + setEaseSpring(); break; + default: + setEaseLinear(); break; + } + + return this; + } + + public LTDescr setEaseLinear(){ this.easeType = LeanTweenType.linear; this.easeMethod = this.easeLinear; return this; } + + public LTDescr setEaseSpring(){ this.easeType = LeanTweenType.easeSpring; this.easeMethod = this.easeSpring; return this; } + + public LTDescr setEaseInQuad(){ this.easeType = LeanTweenType.easeInQuad; this.easeMethod = this.easeInQuad; return this; } + + public LTDescr setEaseOutQuad(){ this.easeType = LeanTweenType.easeOutQuad; this.easeMethod = this.easeOutQuad; return this; } + + public LTDescr setEaseInOutQuad(){ this.easeType = LeanTweenType.easeInOutQuad; this.easeMethod = this.easeInOutQuad; return this;} + + public LTDescr setEaseInCubic(){ this.easeType = LeanTweenType.easeInCubic; this.easeMethod = this.easeInCubic; return this; } + + public LTDescr setEaseOutCubic(){ this.easeType = LeanTweenType.easeOutCubic; this.easeMethod = this.easeOutCubic; return this; } + + public LTDescr setEaseInOutCubic(){ this.easeType = LeanTweenType.easeInOutCubic; this.easeMethod = this.easeInOutCubic; return this; } + + public LTDescr setEaseInQuart(){ this.easeType = LeanTweenType.easeInQuart; this.easeMethod = this.easeInQuart; return this; } + + public LTDescr setEaseOutQuart(){ this.easeType = LeanTweenType.easeOutQuart; this.easeMethod = this.easeOutQuart; return this; } + + public LTDescr setEaseInOutQuart(){ this.easeType = LeanTweenType.easeInOutQuart; this.easeMethod = this.easeInOutQuart; return this; } + + public LTDescr setEaseInQuint(){ this.easeType = LeanTweenType.easeInQuint; this.easeMethod = this.easeInQuint; return this; } + + public LTDescr setEaseOutQuint(){ this.easeType = LeanTweenType.easeOutQuint; this.easeMethod = this.easeOutQuint; return this; } + + public LTDescr setEaseInOutQuint(){ this.easeType = LeanTweenType.easeInOutQuint; this.easeMethod = this.easeInOutQuint; return this; } + + public LTDescr setEaseInSine(){ this.easeType = LeanTweenType.easeInSine; this.easeMethod = this.easeInSine; return this; } + + public LTDescr setEaseOutSine(){ this.easeType = LeanTweenType.easeOutSine; this.easeMethod = this.easeOutSine; return this; } + + public LTDescr setEaseInOutSine(){ this.easeType = LeanTweenType.easeInOutSine; this.easeMethod = this.easeInOutSine; return this; } + + public LTDescr setEaseInExpo(){ this.easeType = LeanTweenType.easeInExpo; this.easeMethod = this.easeInExpo; return this; } + + public LTDescr setEaseOutExpo(){ this.easeType = LeanTweenType.easeOutExpo; this.easeMethod = this.easeOutExpo; return this; } + + public LTDescr setEaseInOutExpo(){ this.easeType = LeanTweenType.easeInOutExpo; this.easeMethod = this.easeInOutExpo; return this; } + + public LTDescr setEaseInCirc(){ this.easeType = LeanTweenType.easeInCirc; this.easeMethod = this.easeInCirc; return this; } + + public LTDescr setEaseOutCirc(){ this.easeType = LeanTweenType.easeOutCirc; this.easeMethod = this.easeOutCirc; return this; } + + public LTDescr setEaseInOutCirc(){ this.easeType = LeanTweenType.easeInOutCirc; this.easeMethod = this.easeInOutCirc; return this; } + + public LTDescr setEaseInBounce(){ this.easeType = LeanTweenType.easeInBounce; this.easeMethod = this.easeInBounce; return this; } + + public LTDescr setEaseOutBounce(){ this.easeType = LeanTweenType.easeOutBounce; this.easeMethod = this.easeOutBounce; return this; } + + public LTDescr setEaseInOutBounce(){ this.easeType = LeanTweenType.easeInOutBounce; this.easeMethod = this.easeInOutBounce; return this; } + + public LTDescr setEaseInBack(){ this.easeType = LeanTweenType.easeInBack; this.easeMethod = this.easeInBack; return this; } + + public LTDescr setEaseOutBack(){ this.easeType = LeanTweenType.easeOutBack; this.easeMethod = this.easeOutBack; return this; } + + public LTDescr setEaseInOutBack(){ this.easeType = LeanTweenType.easeInOutBack; this.easeMethod = this.easeInOutBack; return this; } + + public LTDescr setEaseInElastic(){ this.easeType = LeanTweenType.easeInElastic; this.easeMethod = this.easeInElastic; return this; } + + public LTDescr setEaseOutElastic(){ this.easeType = LeanTweenType.easeOutElastic; this.easeMethod = this.easeOutElastic; return this; } + + public LTDescr setEaseInOutElastic(){ this.easeType = LeanTweenType.easeInOutElastic; this.easeMethod = this.easeInOutElastic; return this; } + + public LTDescr setEasePunch(){ this._optional.animationCurve = LeanTween.punch; this.toInternal.x = this.from.x + this.to.x; this.easeMethod = this.tweenOnCurve; return this; } + + public LTDescr setEaseShake(){ this._optional.animationCurve = LeanTween.shake; this.toInternal.x = this.from.x + this.to.x; this.easeMethod = this.tweenOnCurve; return this; } + + private Vector3 tweenOnCurve(){ + return new Vector3(this.from.x + (this.diff.x) * this._optional.animationCurve.Evaluate(ratioPassed), + this.from.y + (this.diff.y) * this._optional.animationCurve.Evaluate(ratioPassed), + this.from.z + (this.diff.z) * this._optional.animationCurve.Evaluate(ratioPassed) ); + } + + // Vector3 Ease Methods + + private Vector3 easeInOutQuad(){ + val = this.ratioPassed * 2f; + + if (val < 1f) { + val = val * val; + return new Vector3( this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val = (1f-val) * (val - 3f) + 1f; + return new Vector3( this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInQuad(){ + val = ratioPassed * ratioPassed; + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutQuad(){ + val = this.ratioPassed; + val = -val * (val - 2f); + return (this.diff * val + this.from); + } + + private Vector3 easeLinear(){ + val = this.ratioPassed; + return new Vector3(this.from.x+this.diff.x*val, this.from.y+this.diff.y*val, this.from.z+this.diff.z*val); + } + + private Vector3 easeSpring(){ + val = Mathf.Clamp01(this.ratioPassed); + val = (Mathf.Sin(val * Mathf.PI * (0.2f + 2.5f * val * val * val)) * Mathf.Pow(1f - val, 2.2f ) + val) * (1f + (1.2f * (1f - val) )); + return this.from + this.diff * val; + } + + private Vector3 easeInCubic(){ + val = this.ratioPassed * this.ratioPassed * this.ratioPassed; + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutCubic(){ + val = this.ratioPassed - 1f; + val = (val * val * val + 1); + return new Vector3( this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z) ; + } + + private Vector3 easeInOutCubic(){ + val = this.ratioPassed * 2f; + if (val < 1f) { + val = val * val * val; + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val -= 2f; + val = val * val * val + 2f; + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y,this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInQuart(){ + val = this.ratioPassed * this.ratioPassed * this.ratioPassed * this.ratioPassed; + return diff * val + this.from; + } + + private Vector3 easeOutQuart(){ + val = this.ratioPassed - 1f; + val = -(val * val * val * val - 1); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y,this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutQuart(){ + val = this.ratioPassed * 2f; + if (val < 1f) { + val = val * val * val * val; + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val -= 2f; +// val = (val * val * val * val - 2f); + return -this.diffDiv2 * (val * val * val * val - 2f) + this.from; + } + + private Vector3 easeInQuint(){ + val = this.ratioPassed; + val = val * val * val * val * val; + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutQuint(){ + val = this.ratioPassed - 1f; + val = (val * val * val * val * val + 1f); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutQuint(){ + val = this.ratioPassed * 2f; + if (val < 1f){ + val = val * val * val * val * val; + return new Vector3(this.diffDiv2.x * val + this.from.x,this.diffDiv2.y * val + this.from.y,this.diffDiv2.z * val + this.from.z); + } + val -= 2f; + val = (val * val * val * val * val + 2f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInSine(){ + val = - Mathf.Cos(this.ratioPassed * LeanTween.PI_DIV2); + return new Vector3(this.diff.x * val + this.diff.x + this.from.x, this.diff.y * val + this.diff.y + this.from.y, this.diff.z * val + this.diff.z + this.from.z); + } + + private Vector3 easeOutSine(){ + val = Mathf.Sin(this.ratioPassed * LeanTween.PI_DIV2); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y,this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutSine(){ + val = -(Mathf.Cos(Mathf.PI * this.ratioPassed) - 1f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInExpo(){ + val = Mathf.Pow(2f, 10f * (this.ratioPassed - 1f)); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutExpo(){ + val = (-Mathf.Pow(2f, -10f * this.ratioPassed) + 1f); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutExpo(){ + val = this.ratioPassed * 2f; + if (val < 1) return this.diffDiv2 * Mathf.Pow(2, 10 * (val - 1)) + this.from; + val--; + return this.diffDiv2 * (-Mathf.Pow(2, -10 * val) + 2) + this.from; + } + + private Vector3 easeInCirc(){ + val = -(Mathf.Sqrt(1f - this.ratioPassed * this.ratioPassed) - 1f); + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeOutCirc(){ + val = this.ratioPassed - 1f; + val = Mathf.Sqrt(1f - val * val); + + return new Vector3(this.diff.x * val + this.from.x, this.diff.y * val + this.from.y, this.diff.z * val + this.from.z); + } + + private Vector3 easeInOutCirc(){ + val = this.ratioPassed * 2f; + if (val < 1f){ + val = -(Mathf.Sqrt(1f - val * val) - 1f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + val -= 2f; + val = (Mathf.Sqrt(1f - val * val) + 1f); + return new Vector3(this.diffDiv2.x * val + this.from.x, this.diffDiv2.y * val + this.from.y, this.diffDiv2.z * val + this.from.z); + } + + private Vector3 easeInBounce(){ + val = this.ratioPassed; + val = 1f - val; + return new Vector3(this.diff.x - LeanTween.easeOutBounce(0, this.diff.x, val) + this.from.x, + this.diff.y - LeanTween.easeOutBounce(0, this.diff.y, val) + this.from.y, + this.diff.z - LeanTween.easeOutBounce(0, this.diff.z, val) + this.from.z); + } + + private Vector3 easeOutBounce () + { + val = ratioPassed; + float valM, valN; // bounce values + if (val < (valM = 1 - 1.75f * this.overshoot / 2.75f)) { + val = 1 / valM / valM * val * val; + } else if (val < (valN = 1 - .75f * this.overshoot / 2.75f)) { + val -= (valM + valN) / 2; + // first bounce, height: 1/4 + val = 7.5625f * val * val + 1 - .25f * this.overshoot * this.overshoot; + } else if (val < (valM = 1 - .25f * this.overshoot / 2.75f)) { + val -= (valM + valN) / 2; + // second bounce, height: 1/16 + val = 7.5625f * val * val + 1 - .0625f * this.overshoot * this.overshoot; + } else { // valN = 1 + val -= (valM + 1) / 2; + // third bounce, height: 1/64 + val = 7.5625f * val * val + 1 - .015625f * this.overshoot * this.overshoot; + } + return this.diff * val + this.from; + } + + private Vector3 easeInOutBounce(){ + val = this.ratioPassed * 2f; + if (val < 1f){ + return new Vector3(LeanTween.easeInBounce(0, this.diff.x, val) * 0.5f + this.from.x, + LeanTween.easeInBounce(0, this.diff.y, val) * 0.5f + this.from.y, + LeanTween.easeInBounce(0, this.diff.z, val) * 0.5f + this.from.z); + }else { + val = val - 1f; + return new Vector3(LeanTween.easeOutBounce(0, this.diff.x, val) * 0.5f + this.diffDiv2.x + this.from.x, + LeanTween.easeOutBounce(0, this.diff.y, val) * 0.5f + this.diffDiv2.y + this.from.y, + LeanTween.easeOutBounce(0, this.diff.z, val) * 0.5f + this.diffDiv2.z + this.from.z); + } + } + + private Vector3 easeInBack(){ + val = this.ratioPassed; + val /= 1; + float s = 1.70158f * this.overshoot; + return this.diff * (val) * val * ((s + 1) * val - s) + this.from; + } + + private Vector3 easeOutBack(){ + float s = 1.70158f * this.overshoot; + val = (this.ratioPassed / 1) - 1; + val = ((val) * val * ((s + 1) * val + s) + 1); + return this.diff * val + this.from; + } + + private Vector3 easeInOutBack(){ + float s = 1.70158f * this.overshoot; + val = this.ratioPassed * 2f; + if ((val) < 1){ + s *= (1.525f) * overshoot; + return this.diffDiv2 * (val * val * (((s) + 1) * val - s)) + this.from; + } + val -= 2; + s *= (1.525f) * overshoot; + val = ((val) * val * (((s) + 1) * val + s) + 2); + return this.diffDiv2 * val + this.from; + } + + private Vector3 easeInElastic(){ + return new Vector3(LeanTween.easeInElastic(this.from.x,this.to.x,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInElastic(this.from.y,this.to.y,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInElastic(this.from.z,this.to.z,this.ratioPassed,this.overshoot,this.period)); + } + + private Vector3 easeOutElastic(){ + return new Vector3(LeanTween.easeOutElastic(this.from.x,this.to.x,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeOutElastic(this.from.y,this.to.y,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeOutElastic(this.from.z,this.to.z,this.ratioPassed,this.overshoot,this.period)); + } + + private Vector3 easeInOutElastic() + { + return new Vector3(LeanTween.easeInOutElastic(this.from.x,this.to.x,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInOutElastic(this.from.y,this.to.y,this.ratioPassed,this.overshoot,this.period), + LeanTween.easeInOutElastic(this.from.z,this.to.z,this.ratioPassed,this.overshoot,this.period)); + } + + /** + * Set how far past a tween will overshoot for certain ease types (compatible: easeInBack, easeInOutBack, easeOutBack, easeOutElastic, easeInElastic, easeInOutElastic).
+ * @method setOvershoot + * @param {float} overshoot:float how far past the destination it will go before settling in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutBack ).setOvershoot(2f); + */ + public LTDescr setOvershoot( float overshoot ){ + this.overshoot = overshoot; + return this; + } + + /** + * Set how short the iterations are for certain ease types (compatible: easeOutElastic, easeInElastic, easeInOutElastic).
+ * @method setPeriod + * @param {float} period:float how short the iterations are that the tween will animate at (default 0.3f) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutElastic ).setPeriod(0.3f); + */ + public LTDescr setPeriod( float period ){ + this.period = period; + return this; + } + + /** + * Set how large the effect is for certain ease types (compatible: punch, shake, animation curves).
+ * @method setScale + * @param {float} scale:float how much the ease will be multiplied by (default 1f) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.punch ).setScale(2f); + */ + public LTDescr setScale( float scale ){ + this.scale = scale; + return this; + } + + /** + * Set the type of easing used for the tween with a custom curve.
+ * @method setEase (AnimationCurve) + * @param {AnimationCurve} easeDefinition:AnimationCurve an AnimationCure that describes the type of easing you want, this is great for when you want a unique type of movement + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); + */ + public LTDescr setEase( AnimationCurve easeCurve ){ + this._optional.animationCurve = easeCurve; + this.easeMethod = this.tweenOnCurve; + this.easeType = LeanTweenType.animationCurve; + return this; + } + + /** + * Set the end that the GameObject is tweening towards + * @method setTo + * @param {Vector3} to:Vector3 point at which you want the tween to reach + * @return {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) );
+ */ + public LTDescr setTo( Vector3 to ){ + if(this.hasInitiliazed){ + this.to = to; + this.diff = to - this.from; + }else{ + this.to = to; + } + + return this; + } + + public LTDescr setTo( Transform to ){ + this._optional.toTrans = to; + return this; + } + + /** + * Set the beginning of the tween + * @method setFrom + * @param {Vector3} from:Vector3 the point you would like the tween to start at + * @return {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) );
+ */ + public LTDescr setFrom( Vector3 from ){ + if(this.trans){ + this.init(); + } + this.from = from; + // this.hasInitiliazed = true; // this is set, so that the "from" value isn't overwritten later on when the tween starts + this.diff = this.to - this.from; + this.diffDiv2 = this.diff * 0.5f; + return this; + } + + public LTDescr setFrom( float from ){ + return setFrom( new Vector3(from, 0f, 0f) ); + } + + public LTDescr setDiff( Vector3 diff ){ + this.diff = diff; + return this; + } + + public LTDescr setHasInitialized( bool has ){ + this.hasInitiliazed = has; + return this; + } + + public LTDescr setId( uint id, uint global_counter ){ + this._id = id; + this.counter = global_counter; + // Debug.Log("Global counter:"+global_counter); + return this; + } + + /** + * Set the point of time the tween will start in + * @method setPassed + * @param {float} passedTime:float the length of time in seconds the tween will start in + * @return {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 );
+ */ + public LTDescr setPassed( float passed ){ + this.passed = passed; + return this; + } + + /** + * Set the finish time of the tween + * @method setTime + * @param {float} finishTime:float the length of time in seconds you wish the tween to complete in + * @return {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 );
+ */ + public LTDescr setTime( float time ){ + float passedTimeRatio = this.passed / this.time; + this.passed = time * passedTimeRatio; + this.time = time; + return this; + } + + /** + * Set the finish time of the tween + * @method setSpeed + * @param {float} speed:float the speed in unity units per second you wish the object to travel (overrides the given time) + * @return {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
+ */ + public LTDescr setSpeed( float speed ){ + this.speed = speed; + if(this.hasInitiliazed) + initSpeed(); + return this; + } + + /** + * Set the tween to repeat a number of times. + * @method setRepeat + * @param {int} repeatNum:int the number of times to repeat the tween. -1 to repeat infinite times + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong(); + */ + public LTDescr setRepeat( int repeat ){ + this.loopCount = repeat; + if((repeat>1 && this.loopType == LeanTweenType.once) || (repeat < 0 && this.loopType == LeanTweenType.once)){ + this.loopType = LeanTweenType.clamp; + } + if(this.type==TweenAction.CALLBACK || this.type==TweenAction.CALLBACK_COLOR){ + this.setOnCompleteOnRepeat(true); + } + return this; + } + + public LTDescr setLoopType( LeanTweenType loopType ){ + this.loopType = loopType; + return this; + } + + public LTDescr setUseEstimatedTime( bool useEstimatedTime ){ + this.useEstimatedTime = useEstimatedTime; + this.usesNormalDt = false; + return this; + } + + /** + * 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) + * @method setIgnoreTimeScale + * @param {bool} useUnScaledTime:bool whether to use the unscaled time or not + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setIgnoreTimeScale( true ); + */ + public LTDescr setIgnoreTimeScale( bool useUnScaledTime ){ + this.useEstimatedTime = useUnScaledTime; + this.usesNormalDt = false; + return this; + } + + /** + * Use frames when tweening an object, when you don't want the animation to be time-frame independent... + * @method setUseFrames + * @param {bool} useFrames:bool whether to use estimated time or not + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setUseFrames( true ); + */ + public LTDescr setUseFrames( bool useFrames ){ + this.useFrames = useFrames; + this.usesNormalDt = false; + return this; + } + + public LTDescr setUseManualTime( bool useManualTime ){ + this.useManualTime = useManualTime; + this.usesNormalDt = false; + return this; + } + + public LTDescr setLoopCount( int loopCount ){ + this.loopType = LeanTweenType.clamp; + this.loopCount = loopCount; + return this; + } + + /** + * No looping involved, just run once (the default) + * @method setLoopOnce + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopOnce(); + */ + public LTDescr setLoopOnce(){ this.loopType = LeanTweenType.once; return this; } + + /** + * When the animation gets to the end it starts back at where it began + * @method setLoopClamp + * @param {int} loops:int (defaults to -1) how many times you want the loop to happen (-1 for an infinite number of times) + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopClamp( 2 ); + */ + public LTDescr setLoopClamp(){ + this.loopType = LeanTweenType.clamp; + if(this.loopCount==0) + this.loopCount = -1; + return this; + } + public LTDescr setLoopClamp( int loops ){ + this.loopCount = loops; + return this; + } + + /** + * When the animation gets to the end it then tweens back to where it started (and on, and on) + * @method setLoopPingPong + * @param {int} loops: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. + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopPingPong( 2 ); + */ + public LTDescr setLoopPingPong(){ + this.loopType = LeanTweenType.pingPong; + if(this.loopCount==0) + this.loopCount = -1; + return this; + } + public LTDescr setLoopPingPong( int loops ) { + this.loopType = LeanTweenType.pingPong; + this.loopCount = loops == -1 ? loops : loops * 2; + return this; + } + + /** + * Have a method called when the tween finishes + * @method setOnComplete + * @param {Action} onComplete:Action the method that should be called when the tween is finished ex: tweenFinished(){ } + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished ); + */ + public LTDescr setOnComplete( Action onComplete ){ + this._optional.onComplete = onComplete; + this.hasExtraOnCompletes = true; + return this; + } + + /** + * Have a method called when the tween finishes + * @method setOnComplete (object) + * @param {Action} onComplete:Action the method that should be called when the tween is finished ex: tweenFinished( object myObj ){ } + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * object tweenFinishedObj = "hi" as object; + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished, tweenFinishedObj ); + */ + public LTDescr setOnComplete( Action onComplete ){ + this._optional.onCompleteObject = onComplete; + this.hasExtraOnCompletes = true; + return this; + } + public LTDescr setOnComplete( Action onComplete, object onCompleteParam ){ + this._optional.onCompleteObject = onComplete; + this.hasExtraOnCompletes = true; + if(onCompleteParam!=null) + this._optional.onCompleteParam = onCompleteParam; + return this; + } + + /** + * Pass an object to along with the onComplete Function + * @method setOnCompleteParam + * @param {object} onComplete:object an object that + * @return {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]);
+ * }
+ */ + public LTDescr setOnCompleteParam( object onCompleteParam ){ + this._optional.onCompleteParam = onCompleteParam; + this.hasExtraOnCompletes = true; + return this; + } + + + /** + * Have a method called on each frame that the tween is being animated (passes a float value) + * @method setOnUpdate + * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
+ *
+ * void tweenMoved( float val ){ }
+ */ + public LTDescr setOnUpdate( Action onUpdate ){ + this._optional.onUpdateFloat = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateRatio(Action onUpdate) + { + this._optional.onUpdateFloatRatio = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + public LTDescr setOnUpdateObject( Action onUpdate ){ + this._optional.onUpdateFloatObject = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateVector2( Action onUpdate ){ + this._optional.onUpdateVector2 = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateVector3( Action onUpdate ){ + this._optional.onUpdateVector3 = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateColor( Action onUpdate ){ + this._optional.onUpdateColor = onUpdate; + this.hasUpdateCallback = true; + return this; + } + public LTDescr setOnUpdateColor( Action onUpdate ){ + this._optional.onUpdateColorObject = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + #if !UNITY_FLASH + + public LTDescr setOnUpdate( Action onUpdate ){ + this._optional.onUpdateColor = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + public LTDescr setOnUpdate( Action onUpdate ){ + this._optional.onUpdateColorObject = onUpdate; + this.hasUpdateCallback = true; + return this; + } + + /** + * Have a method called on each frame that the tween is being animated (passes a float value and a object) + * @method setOnUpdate (object) + * @param {Action} onUpdate: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 + * @return {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 ){ }
+ */ + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateFloatObject = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateVector3Object = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateVector2 = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + /** + * Have a method called on each frame that the tween is being animated (passes a float value) + * @method setOnUpdate (Vector3) + * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
+ *
+ * void tweenMoved( Vector3 val ){ }
+ */ + public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ + this._optional.onUpdateVector3 = onUpdate; + this.hasUpdateCallback = true; + if(onUpdateParam!=null) + this._optional.onUpdateParam = onUpdateParam; + return this; + } + #endif + + + /** + * Have an object passed along with the onUpdate method + * @method setOnUpdateParam + * @param {object} onUpdateParam:object an object that will be passed along with the onUpdate method + * @return {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 ){ }
+ */ + public LTDescr setOnUpdateParam( object onUpdateParam ){ + this._optional.onUpdateParam = onUpdateParam; + return this; + } + + /** + * While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon + * @method setOrientToPath + * @param {bool} doesOrient:bool whether the gameobject will orient to the path it is animating along + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);
+ */ + public LTDescr setOrientToPath( bool doesOrient ){ + if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ + if(this._optional.path==null) + this._optional.path = new LTBezierPath(); + this._optional.path.orientToPath = doesOrient; + }else{ + this._optional.spline.orientToPath = doesOrient; + } + return this; + } + + /** + * While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon + * @method setOrientToPath2d + * @param {bool} doesOrient:bool whether the gameobject will orient to the path it is animating along + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath2d(true).setAxis(Vector3.forward);
+ */ + public LTDescr setOrientToPath2d( bool doesOrient2d ){ + setOrientToPath(doesOrient2d); + if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ + this._optional.path.orientToPath2d = doesOrient2d; + }else{ + this._optional.spline.orientToPath2d = doesOrient2d; + } + return this; + } + + public LTDescr setRect( LTRect rect ){ + this._optional.ltRect = rect; + return this; + } + + public LTDescr setRect( Rect rect ){ + this._optional.ltRect = new LTRect(rect); + return this; + } + + public LTDescr setPath( LTBezierPath path ){ + this._optional.path = path; + return this; + } + + /** + * Set the point at which the GameObject will be rotated around + * @method setPoint + * @param {Vector3} point:Vector3 point at which you want the object to rotate around (local space) + * @return {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 );
+ */ + public LTDescr setPoint( Vector3 point ){ + this._optional.point = point; + return this; + } + + public LTDescr setDestroyOnComplete( bool doesDestroy ){ + this.destroyOnComplete = doesDestroy; + return this; + } + + public LTDescr setAudio( object audio ){ + this._optional.onCompleteParam = audio; + return this; + } + + /** + * Set the onComplete method to be called at the end of every loop cycle (also applies to the delayedCall method) + * @method setOnCompleteOnRepeat + * @param {bool} isOn:bool does call onComplete on every loop cycle + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.delayedCall(gameObject,0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true); + */ + public LTDescr setOnCompleteOnRepeat( bool isOn ){ + this.onCompleteOnRepeat = isOn; + return this; + } + + /** + * Set the onComplete method to be called at the beginning of the tween (it will still be called when it is completed as well) + * @method setOnCompleteOnStart + * @param {bool} isOn:bool does call onComplete at the start of the tween + * @return {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);
+ */ + public LTDescr setOnCompleteOnStart( bool isOn ){ + this.onCompleteOnStart = isOn; + return this; + } + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + public LTDescr setRect( RectTransform rect ){ + this.rectTransform = rect; + return this; + } + + public LTDescr setSprites( UnityEngine.Sprite[] sprites ){ + this.sprites = sprites; + return this; + } + + public LTDescr setFrameRate( float frameRate ){ + this.time = this.sprites.Length / frameRate; + return this; + } + #endif + + /** + * Have a method called when the tween starts + * @method setOnStart + * @param {Action<>} onStart:Action<> the method that should be called when the tween is starting ex: tweenStarted( ){ } + * @return {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!"); } ); + */ + public LTDescr setOnStart( Action onStart ){ + this._optional.onStart = onStart; + return this; + } + + /** + * Set the direction of a tween -1f for backwards 1f for forwards (currently only bezier and spline paths are supported) + * @method setDirection + * @param {float} direction:float the direction that the tween should run, -1f for backwards 1f for forwards + * @return {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);
+ */ + + public LTDescr setDirection( float direction ){ + if(this.direction!=-1f && this.direction!=1f){ + Debug.LogWarning("You have passed an incorrect direction of '"+direction+"', direction must be -1f or 1f"); + return this; + } + + if(this.direction!=direction){ + // Debug.Log("reverse path:"+this.path+" spline:"+this._optional.spline+" hasInitiliazed:"+this.hasInitiliazed); + if(this.hasInitiliazed){ + this.direction = direction; + }else{ + if(this._optional.path!=null){ + this._optional.path = new LTBezierPath( LTUtility.reverse( this._optional.path.pts ) ); + }else if(this._optional.spline!=null){ + this._optional.spline = new LTSpline( LTUtility.reverse( this._optional.spline.pts ) ); + } + // this.passed = this.time - this.passed; + } + } + + return this; + } + + /** + * Set whether or not the tween will recursively effect an objects children in the hierarchy + * @method setRecursive + * @param {bool} useRecursion:bool whether the tween will recursively effect an objects children in the hierarchy + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alpha(gameObject, 0f, 1f).setRecursive(true);
+ */ + + public LTDescr setRecursive( bool useRecursion ){ + this.useRecursion = useRecursion; + + return this; + } +} + +//} diff --git a/Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs.meta b/Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs.meta new file mode 100644 index 00000000..e47c6280 --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LTDescr.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 381c8d6fb1acdc348870a7147bc98723 +timeCreated: 1463137984 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs b/Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs new file mode 100644 index 00000000..f2b24760 --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs @@ -0,0 +1,88 @@ +//namespace DentedPixel{ +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; + +public class LTDescrOptional { + + public Transform toTrans { get; set; } + public Vector3 point { get; set; } + public Vector3 axis { get; set; } + public float lastVal{ get; set; } + public Quaternion origRotation { get; set; } + public LTBezierPath path { get; set; } + public LTSpline spline { get; set; } + public AnimationCurve animationCurve; + public int initFrameCount; + + public LTRect ltRect { get; set; } // maybe get rid of this eventually + + public Action onUpdateFloat { get; set; } + public Action onUpdateFloatRatio { get; set; } + public Action onUpdateFloatObject { get; set; } + public Action onUpdateVector2 { get; set; } + public Action onUpdateVector3 { get; set; } + public Action onUpdateVector3Object { get; set; } + public Action onUpdateColor { get; set; } + public Action onUpdateColorObject { get; set; } + public Action onComplete { get; set; } + public Action onCompleteObject { get; set; } + public object onCompleteParam { get; set; } + public object onUpdateParam { get; set; } + public Action onStart { get; set; } + + +// #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 +// public SpriteRenderer spriteRen { get; set; } +// #endif +// +// #if LEANTWEEN_1 +// public Hashtable optional; +// #endif +// #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 +// public RectTransform rectTransform; +// public UnityEngine.UI.Text uiText; +// public UnityEngine.UI.Image uiImage; +// public UnityEngine.Sprite[] sprites; +// #endif + + + public void reset(){ + animationCurve = null; + + this.onUpdateFloat = null; + this.onUpdateFloatRatio = null; + this.onUpdateVector2 = null; + this.onUpdateVector3 = null; + this.onUpdateFloatObject = null; + this.onUpdateVector3Object = null; + this.onUpdateColor = null; + this.onComplete = null; + this.onCompleteObject = null; + this.onCompleteParam = null; + this.onStart = null; + + this.point = Vector3.zero; + this.initFrameCount = 0; + } + + public void callOnUpdate( float val, float ratioPassed){ + if(this.onUpdateFloat!=null) + this.onUpdateFloat(val); + + if (this.onUpdateFloatRatio != null){ + this.onUpdateFloatRatio(val,ratioPassed); + }else if(this.onUpdateFloatObject!=null){ + this.onUpdateFloatObject(val, this.onUpdateParam); + }else if(this.onUpdateVector3Object!=null){ + this.onUpdateVector3Object(LTDescr.newVect, this.onUpdateParam); + }else if(this.onUpdateVector3!=null){ + this.onUpdateVector3(LTDescr.newVect); + }else if(this.onUpdateVector2!=null){ + this.onUpdateVector2(new Vector2(LTDescr.newVect.x,LTDescr.newVect.y)); + } + } +} + +//} diff --git a/Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs.meta b/Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs.meta new file mode 100644 index 00000000..8b83a302 --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LTDescrOptional.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c1ba8f1ef97134cb39b52ae26678db63 +timeCreated: 1471504769 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs b/Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs new file mode 100644 index 00000000..f6ab50b6 --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs @@ -0,0 +1,227 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/** +* Internal Representation of a Sequence
+*
+*   

Example:

+* var seq = LeanTween.sequence();
+* seq.append(1f); // delay everything one second
+* seq.append( () => { // fire an event before start
+*  Debug.Log("I have started");
+* });
+* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
+* seq.append( (object obj) => { // fire event after tween
+*  var dict = obj as Dictionary;
+*  Debug.Log("We are done now obj value:"+dict["hi"]);
+* }, new Dictionary(){ {"hi","sup"} } );
+* @class LTSeq +* @constructor +*/ +public class LTSeq { + + public LTSeq previous; + + public LTSeq current; + + public LTDescr tween; + + public float totalDelay; + + public float timeScale; + + private int debugIter; + + public uint counter; + + public bool toggle = false; + + private uint _id; + + public int id{ + get{ + uint toId = _id | counter << 16; + + /*uint backId = toId & 0xFFFF; + uint backCounter = toId >> 16; + if(_id!=backId || backCounter!=counter){ + Debug.LogError("BAD CONVERSION toId:"+_id); + }*/ + + return (int)toId; + } + } + + public void reset(){ + previous = null; + tween = null; + totalDelay = 0f; + } + + public void init(uint id, uint global_counter){ + reset(); + _id = id; + + counter = global_counter; + + this.current = this; + } + + private LTSeq addOn(){ + this.current.toggle = true; + LTSeq lastCurrent = this.current; + this.current = LeanTween.sequence(true); + Debug.Log("this.current:" + this.current.id + " lastCurrent:" + lastCurrent.id); + this.current.previous = lastCurrent; + lastCurrent.toggle = false; + this.current.totalDelay = lastCurrent.totalDelay; + this.current.debugIter = lastCurrent.debugIter + 1; + return current; + } + + private float addPreviousDelays(){ +// Debug.Log("delay:"+delay+" count:"+this.current.count+" this.current.totalDelay:"+this.current.totalDelay); + + LTSeq prev = this.current.previous; + + if (prev != null && prev.tween!=null) { + return this.current.totalDelay + prev.tween.time; + } + return this.current.totalDelay; + } + + /** + * Add a time delay to the sequence + * @method append (delay) + * @param {float} delay:float amount of time to add to the sequence + * @return {LTSeq} LTDescr an object that distinguishes the tween + * var seq = LeanTween.sequence();
+ * seq.append(1f); // delay everything one second
+ * seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
+ */ + public LTSeq append( float delay ){ + this.current.totalDelay += delay; + + return this.current; + } + + /** + * Add a time delay to the sequence + * @method append (method) + * @param {System.Action} callback:System.Action method you want to be called + * @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to + * @example + * var seq = LeanTween.sequence();
+ * seq.append( () => { // fire an event before start
+ *  Debug.Log("I have started");
+ * });
+ * seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
+ * seq.append( () => { // fire event after tween
+ *  Debug.Log("We are done now");
+ * });;
+ */ + public LTSeq append( System.Action callback ){ + LTDescr newTween = LeanTween.delayedCall(0f, callback); +// Debug.Log("newTween:" + newTween); + append(newTween); + + return addOn(); + } + + /** + * Add a time delay to the sequence + * @method add (method(object)) + * @param {System.Action} callback:System.Action method you want to be called + * @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to + * @example + * var seq = LeanTween.sequence();
+ * seq.append( () => { // fire an event before start
+ *  Debug.Log("I have started");
+ * });
+ * seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
+ * seq.append((object obj) => { // fire event after tween + *  var dict = obj as Dictionary; + *  Debug.Log("We are done now obj value:"+dict["hi"]); + *  }, new Dictionary(){ {"hi","sup"} } ); + */ + public LTSeq append( System.Action callback, object obj ){ + append(LeanTween.delayedCall(0f, callback).setOnCompleteParam(obj)); + + return addOn(); + } + + public LTSeq append( GameObject gameObject, System.Action callback ){ + append(LeanTween.delayedCall(gameObject, 0f, callback)); + + return addOn(); + } + + public LTSeq append( GameObject gameObject, System.Action callback, object obj ){ + append(LeanTween.delayedCall(gameObject, 0f, callback).setOnCompleteParam(obj)); + + return addOn(); + } + + /** + * Retrieve a sequencer object where you can easily chain together tweens and methods one after another + * + * @method add (tween) + * @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to + * @example + * var seq = LeanTween.sequence();
+ * seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a move tween
+ * seq.append( LeanTween.rotateAround( avatar1, Vector3.forward, 360f, 1f ) ); // then do a rotate tween
+ */ + public LTSeq append( LTDescr tween ){ + this.current.tween = tween; + +// Debug.Log("tween:" + tween + " delay:" + this.current.totalDelay); + + this.current.totalDelay = addPreviousDelays(); + + tween.setDelay( this.current.totalDelay ); + + return addOn(); + } + + public LTSeq insert( LTDescr tween ){ + this.current.tween = tween; + + tween.setDelay( addPreviousDelays() ); + + return addOn(); + } + + + public LTSeq setScale( float timeScale ){ +// Debug.Log("this.current:" + this.current.previous.debugIter+" tween:"+this.current.previous.tween); + setScaleRecursive(this.current, timeScale, 500); + + return addOn(); + } + + private void setScaleRecursive( LTSeq seq, float timeScale, int count ){ + if (count > 0) { + this.timeScale = timeScale; + +// Debug.Log("seq.count:" + count + " seq.tween:" + seq.tween); + seq.totalDelay *= timeScale; + if (seq.tween != null) { +// Debug.Log("seq.tween.time * timeScale:" + seq.tween.time * timeScale + " seq.totalDelay:"+seq.totalDelay +" time:"+seq.tween.time+" seq.tween.delay:"+seq.tween.delay); + if (seq.tween.time != 0f) + seq.tween.setTime(seq.tween.time * timeScale); + seq.tween.setDelay(seq.tween.delay * timeScale); + } + + if (seq.previous != null) + setScaleRecursive(seq.previous, timeScale, count - 1); + } + } + + public LTSeq reverse(){ + + return addOn(); + } + +} diff --git a/Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs.meta b/Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs.meta new file mode 100644 index 00000000..c9b68c4e --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LTSeq.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6c88dbe4cdd9944f198e9796ee394c86 +timeCreated: 1488665079 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs b/Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs new file mode 100644 index 00000000..b7d1939b --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs @@ -0,0 +1,418 @@ + +using UnityEngine; +using System.Collections.Generic; + +public class LeanAudioStream { + + public int position = 0; + + public AudioClip audioClip; + public float[] audioArr; + + public LeanAudioStream( float[] audioArr ){ + this.audioArr = audioArr; + } + + public void OnAudioRead(float[] data) { + int count = 0; + while (count < data.Length) { + data[count] = audioArr[this.position]; + position++; + count++; + } + } + + public void OnAudioSetPosition(int newPosition) { + this.position = newPosition; + } +} + +/** +* Create Audio dynamically and easily playback +* +* @class LeanAudio +* @constructor +*/ +public class LeanAudio : object { + + public static float MIN_FREQEUNCY_PERIOD = 0.000115f; + public static int PROCESSING_ITERATIONS_MAX = 50000; + public static float[] generatedWaveDistances; + public static int generatedWaveDistancesCount = 0; + + private static float[] longList; + + public static LeanAudioOptions options(){ + if(generatedWaveDistances==null){ + generatedWaveDistances = new float[ PROCESSING_ITERATIONS_MAX ]; + longList = new float[ PROCESSING_ITERATIONS_MAX ]; + } + return new LeanAudioOptions(); + } + + public static LeanAudioStream createAudioStream( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options = null ){ + if(options==null) + options = new LeanAudioOptions(); + + options.useSetData = false; + + int generatedWavePtsLength = createAudioWave( volume, frequency, options); + createAudioFromWave( generatedWavePtsLength, options ); + + return options.stream; + } + + /** + * Create dynamic audio from a set of Animation Curves and other options. + * + * @method createAudio + * @param {AnimationCurve} volumeCurve:AnimationCurve describing the shape of the audios volume (from 0-1). The length of the audio is dicated by the end value here. + * @param {AnimationCurve} frequencyCurve:AnimationCurve describing the width of the oscillations between the sound waves in seconds. Large numbers mean a lower note, while higher numbers mean a tighter frequency and therefor a higher note. Values are usually between 0.01 and 0.000001 (or smaller) + * @param {LeanAudioOptions} options:LeanAudioOptions You can pass any other values in here like vibrato or the frequency you would like the sound to be encoded at. See LeanAudioOptions for more details. + * @return {AudioClip} AudioClip of the procedurally generated audio + * @example + * AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
+ * AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
+ * AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ));
+ */ + public static AudioClip createAudio( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options = null ){ + if(options==null) + options = new LeanAudioOptions(); + + int generatedWavePtsLength = createAudioWave( volume, frequency, options); + // Debug.Log("generatedWavePtsLength:"+generatedWavePtsLength); + return createAudioFromWave( generatedWavePtsLength, options ); + } + + private static int createAudioWave( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options ){ + float time = volume[ volume.length - 1 ].time; + int listLength = 0; + // List list = new List(); + + // generatedWaveDistances = new List(); + // float[] vibratoValues = new float[ vibrato.Length ]; + float passed = 0f; + for(int i = 0; i < PROCESSING_ITERATIONS_MAX; i++){ + float f = frequency.Evaluate(passed); + if(f=time) + break; + if(listLength >= PROCESSING_ITERATIONS_MAX-1){ + Debug.LogError("LeanAudio has reached it's processing cap. To avoid this error increase the number of iterations ex: LeanAudio.PROCESSING_ITERATIONS_MAX = "+(PROCESSING_ITERATIONS_MAX*2)); + break; + }else{ + int distPoint = listLength / 2; + + //generatedWaveDistances.Add( f ); + passed += f; + + generatedWaveDistances[ distPoint ] = passed; + //Debug.Log("distPoint:"+distPoint+" passed:"+passed); + + //list.Add( passed ); + //list.Add( i%2==0 ? -height : height ); + + longList[ listLength ] = passed; + longList[ listLength + 1 ] = i%2==0 ? -height : height; + } + + + + listLength += 2; + + } + + listLength += -2; + generatedWaveDistancesCount = listLength / 2; + + /*float[] wave = new float[ listLength ]; + for(int i = 0; i < wave.Length; i++){ + wave[i] = longList[i]; + }*/ + return listLength; + } + + private static AudioClip createAudioFromWave( int waveLength, LeanAudioOptions options ){ + float time = longList[ waveLength - 2 ]; + float[] audioArr = new float[ (int)(options.frequencyRate*time) ]; + + int waveIter = 0; + float subWaveDiff = longList[waveIter]; + float subWaveTimeLast = 0f; + float subWaveTime = longList[waveIter]; + float waveHeight = longList[waveIter+1]; + for(int i = 0; i < audioArr.Length; i++){ + float passedTime = (float)i / (float)options.frequencyRate; + if(passedTime > longList[waveIter] ){ + subWaveTimeLast = longList[waveIter]; + waveIter += 2; + subWaveDiff = longList[waveIter] - longList[waveIter-2]; + waveHeight = longList[waveIter+1]; + // Debug.Log("passed wave i:"+i); + } + subWaveTime = passedTime - subWaveTimeLast; + float ratioElapsed = subWaveTime / subWaveDiff; + + float value = Mathf.Sin( ratioElapsed * Mathf.PI ); + + if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Square){ + if(value>0f) + value = 1f; + if(value<0f) + value = -1f; + }else if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Sawtooth){ + float sign = value > 0f ? 1f : -1f; + if(ratioElapsed<0.5f){ + value = (ratioElapsed*2f)*sign; + }else{ // 0.5f - 1f + value = (1f - ratioElapsed)*2f*sign; + } + }else if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Noise){ + float peakMulti = (1f-options.waveNoiseInfluence) + Mathf.PerlinNoise(0f, passedTime * options.waveNoiseScale ) * options.waveNoiseInfluence; + + /*if(i<25){ + Debug.Log("passedTime:"+passedTime+" peakMulti:"+peakMulti+" infl:"+options.waveNoiseInfluence); + }*/ + + value *= peakMulti; + } + + //if(i<25) + // Debug.Log("passedTime:"+passedTime+" value:"+value+" ratioElapsed:"+ratioElapsed+" subWaveTime:"+subWaveTime+" subWaveDiff:"+subWaveDiff); + + value *= waveHeight; + + + if(options.modulation!=null){ + for(int k=0; k(); // add an audio source + aSource.clip = clip; // define the clip + aSource.Play(); // start the sound + GameObject.Destroy(tempGO, clip.length); // destroy object after clip duration + return aSource; // return the AudioSource reference + } + + public static void printOutAudioClip( AudioClip audioClip, ref AnimationCurve curve, float scaleX = 1f ){ + // Debug.Log("Audio channels:"+audioClip.channels+" frequency:"+audioClip.frequency+" length:"+audioClip.length+" samples:"+audioClip.samples); + float[] samples = new float[audioClip.samples * audioClip.channels]; + audioClip.GetData(samples, 0); + int i = 0; + + Keyframe[] frames = new Keyframe[samples.Length]; + while (i < samples.Length) { + frames[i] = new Keyframe( (float)i * scaleX, samples[i] ); + ++i; + } + curve = new AnimationCurve( frames ); + } +} + + +/** +* Pass in options to LeanAudio +* +* @class LeanAudioOptions +* @constructor +*/ +public class LeanAudioOptions : object { + + public enum LeanAudioWaveStyle{ + Sine, + Square, + Sawtooth, + Noise + } + + public LeanAudioWaveStyle waveStyle = LeanAudioWaveStyle.Sine; + public Vector3[] vibrato; + public Vector3[] modulation; + public int frequencyRate = 44100; + public float waveNoiseScale = 1000; + public float waveNoiseInfluence = 1f; + + public bool useSetData = true; + public LeanAudioStream stream; + + public LeanAudioOptions(){} + + /** + * Set the frequency for the audio is encoded. 44100 is CD quality, but you can usually get away with much lower (or use a lower amount to get a more 8-bit sound). + * + * @method setFrequency + * @param {int} frequencyRate:int of the frequency you wish to encode the AudioClip at + * @return {LeanAudioOptions} LeanAudioOptions describing optional values + * @example + * AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
+ * AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
+ * AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ).setFrequency(12100) );
+ */ + public LeanAudioOptions setFrequency( int frequencyRate ){ + this.frequencyRate = frequencyRate; + return this; + } + + /** + * Set details about the shape of the curve by adding vibrato modulations through it (alters the peak values giving it a wah-wah effect). You can add as many as you want to sculpt out more detail in the sound wave. + * + * @method setVibrato + * @param {Vector3[]} vibratoArray:Vector3[] The first value is the period in seconds that you wish to have the vibrato wave fluctuate at. The second value is the minimum height you wish the vibrato wave to dip down to (default is zero). The third is reserved for future effects. + * @return {LeanAudioOptions} LeanAudioOptions describing optional values + * @example + * AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));
+ * AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));
+ * AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0.3f,0f)} ).setFrequency(12100) );
+ */ + public LeanAudioOptions setVibrato( Vector3[] vibrato ){ + this.vibrato = vibrato; + return this; + } + + /* + public LeanAudioOptions setModulation( Vector3[] modulation ){ + this.modulation = modulation; + return this; + }*/ + + public LeanAudioOptions setWaveSine(){ + this.waveStyle = LeanAudioWaveStyle.Sine; + return this; + } + + public LeanAudioOptions setWaveSquare(){ + this.waveStyle = LeanAudioWaveStyle.Square; + return this; + } + + public LeanAudioOptions setWaveSawtooth(){ + this.waveStyle = LeanAudioWaveStyle.Sawtooth; + return this; + } + + public LeanAudioOptions setWaveNoise(){ + this.waveStyle = LeanAudioWaveStyle.Noise; + return this; + } + + public LeanAudioOptions setWaveStyle( LeanAudioWaveStyle style ){ + this.waveStyle = style; + return this; + } + + + public LeanAudioOptions setWaveNoiseScale( float waveScale ){ + this.waveNoiseScale = waveScale; + return this; + } + + public LeanAudioOptions setWaveNoiseInfluence( float influence ){ + this.waveNoiseInfluence = influence; + return this; + } +} + + diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs.meta b/Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs.meta new file mode 100644 index 00000000..cd86bafe --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanAudio.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 52e41e970d9353942b27458440bec9eb +timeCreated: 1427917971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs b/Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs new file mode 100644 index 00000000..82896223 --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs @@ -0,0 +1,123 @@ +using UnityEngine; +using System.Collections; + +public class LeanTester : MonoBehaviour { + public float timeout = 15f; + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + public void Start(){ + StartCoroutine( timeoutCheck() ); + } + + IEnumerator timeoutCheck(){ + float pauseEndTime = Time.realtimeSinceStartup + timeout; + while (Time.realtimeSinceStartup < pauseEndTime) + { + yield return 0; + } + if(LeanTest.testsFinished==false){ + Debug.Log(LeanTest.formatB("Tests timed out!")); + LeanTest.overview(); + } + } + #endif +} + +public class LeanTest : object { + public static int expected = 0; + private static int tests = 0; + private static int passes = 0; + + public static float timeout = 15f; + public static bool timeoutStarted = false; + public static bool testsFinished = false; + + public static void debug( string name, bool didPass, string failExplaination = null){ + expect( didPass, name, failExplaination); + } + + public static void expect( bool didPass, string definition, string failExplaination = null){ + float len = printOutLength(definition); + int paddingLen = 40-(int)(len*1.05f); + #if UNITY_FLASH + string padding = padRight(paddingLen); + #else + string padding = "".PadRight(paddingLen,"_"[0]); + #endif + string logName = formatB(definition) +" " + padding + " [ "+ (didPass ? formatC("pass","green") : formatC("fail","red")) +" ]"; + if(didPass==false && failExplaination!=null) + logName += " - " + failExplaination; + Debug.Log(logName); + if(didPass) + passes++; + tests++; + + // Debug.Log("tests:"+tests+" expected:"+expected); + if(tests==expected && testsFinished==false){ + overview(); + }else if(tests>expected){ + Debug.Log(formatB("Too many tests for a final report!") + " set LeanTest.expected = "+tests); + } + + if(timeoutStarted==false){ + timeoutStarted = true; + GameObject tester = new GameObject(); + tester.name = "~LeanTest"; + LeanTester test = tester.AddComponent(typeof(LeanTester)) as LeanTester; + test.timeout = timeout; + #if !UNITY_EDITOR + tester.hideFlags = HideFlags.HideAndDontSave; + #endif + } + } + + public static string padRight(int len){ + string str = ""; + for(int i = 0; i < len; i++){ + str += "_"; + } + return str; + } + + public static float printOutLength( string str ){ + float len = 0.0f; + for(int i = 0; i < str.Length; i++){ + if(str[i]=="I"[0]){ + len += 0.5f; + }else if(str[i]=="J"[0]){ + len += 0.85f; + }else{ + len += 1.0f; + } + } + return len; + } + + public static string formatBC( string str, string color ){ + return formatC(formatB(str),color); + } + + public static string formatB( string str ){ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + return str; + #else + return ""+ str + ""; + #endif + } + + public static string formatC( string str, string color ){ + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 + return str; + #else + return ""+ str + ""; + #endif + } + + public static void overview(){ + testsFinished = true; + int failedCnt = (expected-passes); + string failedStr = failedCnt > 0 ? formatBC(""+failedCnt,"red") : ""+failedCnt; + Debug.Log(formatB("Final Report:")+" _____________________ PASSED: "+formatBC(""+passes,"green")+" FAILED: "+failedStr+" "); + } +} + \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs.meta b/Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs.meta new file mode 100644 index 00000000..0af8aa2a --- /dev/null +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanTest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 82464f26ca2ba284a8f92f51248c574a +timeCreated: 1427917971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs index 8e4cee38..68f025c8 100644 --- a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs @@ -1,6 +1,10 @@ -// Copyright (c) 2015 Russell Savage - Dented Pixel -// -// LeanTween version 2.30 - http://dentedpixel.com/developer-diary/ +//namespace DentedPixel{ + +// LeanTween version 2.46 - http://dentedpixel.com/developer-diary/ +// +// The MIT License (MIT) +// +// Copyright (c) 2017 Russell Savage - Dented Pixel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -9,16 +13,18 @@ // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + /* TERMS OF USE - EASING EQUATIONS# @@ -33,8 +39,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ /** -* Pass this to the "ease" parameter, to get a different easing behavior

-* Example:
LeanTween.rotateX(gameObject, 270.0f, 1.5f).setEase(LeanTweenType.easeInBack); +* Pass this to the "ease" parameter, to get a different easing behavior

+* Example:
LeanTween.rotateX(gameObject, 270.0f, 1.5f).setEase(LeanTweenType.easeInBack); * * @class LeanTweenType */ @@ -136,2196 +142,519 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * @property {integer} punch */ using UnityEngine; -using System.Collections; using System; -using System.Runtime.InteropServices; using System.Collections.Generic; public enum TweenAction{ - MOVE_X, - MOVE_Y, - MOVE_Z, - MOVE_LOCAL_X, - MOVE_LOCAL_Y, - MOVE_LOCAL_Z, - MOVE_CURVED, - MOVE_CURVED_LOCAL, - MOVE_SPLINE, - MOVE_SPLINE_LOCAL, - SCALE_X, - SCALE_Y, - SCALE_Z, - ROTATE_X, - ROTATE_Y, - ROTATE_Z, - ROTATE_AROUND, - ROTATE_AROUND_LOCAL, - CANVAS_ROTATEAROUND, - CANVAS_ROTATEAROUND_LOCAL, - CANVAS_PLAYSPRITE, - ALPHA, + MOVE_X, + MOVE_Y, + MOVE_Z, + MOVE_LOCAL_X, + MOVE_LOCAL_Y, + MOVE_LOCAL_Z, + MOVE_CURVED, + MOVE_CURVED_LOCAL, + MOVE_SPLINE, + MOVE_SPLINE_LOCAL, + SCALE_X, + SCALE_Y, + SCALE_Z, + ROTATE_X, + ROTATE_Y, + ROTATE_Z, + ROTATE_AROUND, + ROTATE_AROUND_LOCAL, + CANVAS_ROTATEAROUND, + CANVAS_ROTATEAROUND_LOCAL, + CANVAS_PLAYSPRITE, + ALPHA, TEXT_ALPHA, CANVAS_ALPHA, + CANVASGROUP_ALPHA, ALPHA_VERTEX, - COLOR, - CALLBACK_COLOR, + COLOR, + CALLBACK_COLOR, TEXT_COLOR, - CANVAS_COLOR, - CANVAS_MOVE_X, - CANVAS_MOVE_Y, - CANVAS_MOVE_Z, - CALLBACK, - MOVE, - MOVE_LOCAL, - ROTATE, - ROTATE_LOCAL, - SCALE, - VALUE3, - GUI_MOVE, - GUI_MOVE_MARGIN, - GUI_SCALE, - GUI_ALPHA, - GUI_ROTATE, - DELAYED_SOUND, - CANVAS_MOVE, - CANVAS_SCALE, + CANVAS_COLOR, + CANVAS_MOVE_X, + CANVAS_MOVE_Y, + CANVAS_MOVE_Z, + CALLBACK, + MOVE, + MOVE_LOCAL, + MOVE_TO_TRANSFORM, + ROTATE, + ROTATE_LOCAL, + SCALE, + VALUE3, + GUI_MOVE, + GUI_MOVE_MARGIN, + GUI_SCALE, + GUI_ALPHA, + GUI_ROTATE, + DELAYED_SOUND, + CANVAS_MOVE, + CANVAS_SCALE, + CANVAS_SIZEDELTA, } public enum LeanTweenType{ - notUsed, linear, easeOutQuad, easeInQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, - easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, - easeInBounce, easeOutBounce, easeInOutBounce, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeSpring, easeShake, punch, once, clamp, pingPong, animationCurve + notUsed, linear, easeOutQuad, easeInQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, + easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, + easeInBounce, easeOutBounce, easeInOutBounce, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeSpring, easeShake, punch, once, clamp, pingPong, animationCurve } /** -* 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);
-*   }
-* @class LTDescr -* @constructor +* LeanTween is an efficient tweening engine for Unity3d

+* Index of All Methods | Optional Paramaters that can be passed

+* 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 modify this tween later, just save the unique id of the tween.
+*

Example:

+* int id = LeanTween.moveX(gameObject, 1f, 1f).id;
+* LTDescr d = LeanTween.descr( id );

+* if(d!=null){ // if the tween has already finished it will return null
+*    // change some parameters
+*    d.setOnComplete( onCompleteFunc ).setEase( LeanTweenType.easeInOutBack );
+* } +* +* @class LeanTween */ -public class LTDescr { - public bool toggle; - public bool useEstimatedTime; - public bool useFrames; - public bool useManualTime; - public bool hasInitiliazed; - public bool hasPhysics; - public bool onCompleteOnRepeat; - public bool onCompleteOnStart; - public float passed; - public float delay; - public float time; - public float lastVal; - private uint _id; - public int loopCount; - public uint counter; - public float direction; - public float directionLast; - public float overshoot; - public float period; - public bool destroyOnComplete; - public Transform trans; - public LTRect ltRect; - public Vector3 from; - public Vector3 to; - public Vector3 diff; - public Vector3 point; - public Vector3 axis; - public Quaternion origRotation; - public LTBezierPath path; - public LTSpline spline; - public TweenAction type; - public LeanTweenType tweenType; - public AnimationCurve animationCurve; - public LeanTweenType loopType; - public bool hasUpdateCallback; - public Action onUpdateFloat; - public Action onUpdateFloatRatio; - public Action onUpdateFloatObject; - public Action onUpdateVector2; - public Action onUpdateVector3; - public Action onUpdateVector3Object; - public Action onUpdateColor; - public Action onComplete; - public Action onCompleteObject; - public object onCompleteParam; - public object onUpdateParam; - public Action onStart; - - #if LEANTWEEN_1 - public Hashtable optional; - #endif - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 - public RectTransform rectTransform; - public UnityEngine.UI.Text uiText; - public UnityEngine.UI.Image uiImage; - public UnityEngine.Sprite[] sprites; - #endif - - private static uint global_counter = 0; +public class LeanTween : MonoBehaviour { - public override string ToString(){ - return (trans!=null ? "gameObject:"+trans.gameObject : "gameObject:null")+" toggle:"+toggle+" passed:"+passed+" time:"+time+" delay:"+delay+" direction:"+direction+" from:"+from+" to:"+to+" type:"+type+" ease:"+tweenType+" useEstimatedTime:"+useEstimatedTime+" id:"+id+" hasInitiliazed:"+hasInitiliazed; - } - - public LTDescr(){ - - } - - [System.Obsolete("Use 'LeanTween.cancel( id )' instead")] - public LTDescr cancel( GameObject gameObject ){ - // Debug.Log("canceling id:"+this._id+" this.uniqueId:"+this.uniqueId+" go:"+this.trans.gameObject); - if(gameObject==this.trans.gameObject) - LeanTween.removeTween((int)this._id, this.uniqueId); - return this; - } - - /*[System.Obsolete("Use 'LeanTween.cancel( id )' instead")] - public LTDescr cancel(){ - // Debug.Log("canceling id:"+this._id+" this.uniqueId:"+this.uniqueId+" go:"+this.trans.gameObject); - LeanTween.removeTween((int)this._id); - return this; - }*/ - - public int uniqueId{ - get{ - uint toId = _id | counter << 16; - - /*uint backId = toId & 0xFFFF; - uint backCounter = toId >> 16; - if(_id!=backId || backCounter!=counter){ - Debug.LogError("BAD CONVERSION toId:"+_id); - }*/ - - return (int)toId; - } - } - - public int id{ - get{ - return uniqueId; - } - } - - public void reset(){ - this.toggle = true; - #if LEANTWEEN_1 - this.optional = null; - #endif - this.trans = null; - this.passed = this.delay = this.lastVal = 0.0f; - this.hasUpdateCallback = this.useEstimatedTime = this.useFrames = this.hasInitiliazed = this.onCompleteOnRepeat = this.destroyOnComplete = this.onCompleteOnStart = this.useManualTime = false; - this.animationCurve = null; - this.tweenType = LeanTweenType.linear; - this.loopType = LeanTweenType.once; - this.loopCount = 0; - this.direction = this.directionLast = this.overshoot = 1.0f; - this.period = 0.3f; - this.point = Vector3.zero; - cleanup(); - - global_counter++; - if(global_counter>0x8000) - global_counter = 0; - } - - public void cleanup(){ - this.onUpdateFloat = null; - this.onUpdateFloatRatio = null; - this.onUpdateVector2 = null; - this.onUpdateVector3 = null; - this.onUpdateFloatObject = null; - this.onUpdateVector3Object = null; - this.onUpdateColor = null; - this.onComplete = null; - this.onCompleteObject = null; - this.onCompleteParam = null; - this.onStart = null; - - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 - this.rectTransform = null; - this.uiText = null; - this.uiImage = null; - this.sprites = null; - #endif - } - - // This method is only for internal use - public void init(){ - this.hasInitiliazed = true; - - if (this.onStart != null){ - this.onStart(); - } - - // Initialize From Values - switch(this.type){ - case TweenAction.MOVE: - this.from = trans.position; break; - case TweenAction.MOVE_X: - this.from.x = trans.position.x; break; - case TweenAction.MOVE_Y: - this.from.x = trans.position.y; break; - case TweenAction.MOVE_Z: - this.from.x = trans.position.z; break; - case TweenAction.MOVE_LOCAL_X: - this.from.x = trans.localPosition.x; break; - case TweenAction.MOVE_LOCAL_Y: - this.from.x = trans.localPosition.y; break; - case TweenAction.MOVE_LOCAL_Z: - this.from.x = trans.localPosition.z; break; - case TweenAction.SCALE_X: - this.from.x = trans.localScale.x; break; - case TweenAction.SCALE_Y: - this.from.x = trans.localScale.y; break; - case TweenAction.SCALE_Z: - this.from.x = trans.localScale.z; break; - case TweenAction.ALPHA: - #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 - if(trans.gameObject.renderer){ - this.from.x = trans.gameObject.renderer.material.color.a; - }else if(trans.childCount>0){ - foreach (Transform child in trans) { - if(child.gameObject.renderer!=null){ - Color col = child.gameObject.renderer.material.color; - this.from.x = col.a; - break; - } - } - } - break; - #else - SpriteRenderer ren = trans.gameObject.GetComponent(); - if(ren!=null){ - this.from.x = ren.color.a; - }else{ - if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_Color")){ - this.from.x = trans.gameObject.GetComponent().material.color.a; - }else if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_TintColor")){ - Color col = trans.gameObject.GetComponent().material.GetColor("_TintColor"); - this.from.x = col.a; - }else if(trans.childCount>0){ - foreach (Transform child in trans) { - if(child.gameObject.GetComponent()!=null){ - Color col = child.gameObject.GetComponent().material.color; - this.from.x = col.a; - break; - } - } - } - } - break; - #endif - case TweenAction.MOVE_LOCAL: - this.from = trans.localPosition; break; - case TweenAction.MOVE_CURVED: - case TweenAction.MOVE_CURVED_LOCAL: - case TweenAction.MOVE_SPLINE: - case TweenAction.MOVE_SPLINE_LOCAL: - this.from.x = 0; break; - case TweenAction.ROTATE: - this.from = trans.eulerAngles; - this.to = new Vector3(LeanTween.closestRot( this.from.x, this.to.x), LeanTween.closestRot( this.from.y, this.to.y), LeanTween.closestRot( this.from.z, this.to.z)); - break; - case TweenAction.ROTATE_X: - this.from.x = trans.eulerAngles.x; - this.to.x = LeanTween.closestRot( this.from.x, this.to.x); - break; - case TweenAction.ROTATE_Y: - this.from.x = trans.eulerAngles.y; - this.to.x = LeanTween.closestRot( this.from.x, this.to.x); - break; - case TweenAction.ROTATE_Z: - this.from.x = trans.eulerAngles.z; - this.to.x = LeanTween.closestRot( this.from.x, this.to.x); - break; - case TweenAction.ROTATE_AROUND: - this.lastVal = 0.0f; // optional["last"] - this.from.x = 0.0f; - this.origRotation = trans.rotation; // optional["origRotation" - break; - case TweenAction.ROTATE_AROUND_LOCAL: - this.lastVal = 0.0f; // optional["last"] - this.from.x = 0.0f; - this.origRotation = trans.localRotation; // optional["origRotation" - break; - case TweenAction.ROTATE_LOCAL: - this.from = trans.localEulerAngles; - this.to = new Vector3(LeanTween.closestRot( this.from.x, this.to.x), LeanTween.closestRot( this.from.y, this.to.y), LeanTween.closestRot( this.from.z, this.to.z)); - break; - case TweenAction.SCALE: - this.from = trans.localScale; break; - case TweenAction.GUI_MOVE: - this.from = new Vector3(this.ltRect.rect.x, this.ltRect.rect.y, 0); break; - case TweenAction.GUI_MOVE_MARGIN: - this.from = new Vector2(this.ltRect.margin.x, this.ltRect.margin.y); break; - case TweenAction.GUI_SCALE: - this.from = new Vector3(this.ltRect.rect.width, this.ltRect.rect.height, 0); break; - case TweenAction.GUI_ALPHA: - this.from.x = this.ltRect.alpha; break; - case TweenAction.GUI_ROTATE: - if(this.ltRect.rotateEnabled==false){ - this.ltRect.rotateEnabled = true; - this.ltRect.resetForRotation(); - } - - this.from.x = this.ltRect.rotation; break; - case TweenAction.ALPHA_VERTEX: - this.from.x = trans.GetComponent().mesh.colors32[0].a; - break; - case TweenAction.CALLBACK: - break; - case TweenAction.CALLBACK_COLOR: - this.diff = new Vector3(1.0f,0.0f,0.0f); - break; - case TweenAction.COLOR: - #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 - if(trans.gameObject.renderer){ - Color col = trans.gameObject.renderer.material.color; - this.setFromColor( col ); - }else if(trans.childCount>0){ - foreach (Transform child in trans) { - if(child.gameObject.renderer!=null){ - Color col = child.gameObject.renderer.material.color; - this.setFromColor( col ); - break; - } - } - } - #else - SpriteRenderer renColor = trans.gameObject.GetComponent(); - if(renColor!=null){ - Color col = renColor.color; - this.setFromColor( col ); - }else{ - if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_Color")){ - Color col = trans.gameObject.GetComponent().material.color; - this.setFromColor( col ); - }else if(trans.gameObject.GetComponent()!=null && trans.gameObject.GetComponent().material.HasProperty("_TintColor")){ - Color col = trans.gameObject.GetComponent().material.GetColor ("_TintColor"); - this.setFromColor( col ); - }else if(trans.childCount>0){ - foreach (Transform child in trans) { - if(child.gameObject.GetComponent()!=null){ - Color col = child.gameObject.GetComponent().material.color; - this.setFromColor( col ); - break; - } - } - } - } - #endif - break; - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 - case TweenAction.CANVAS_ALPHA: - this.uiImage = trans.gameObject.GetComponent(); - if(this.uiImage != null) - this.from.x = this.uiImage.color.a; - break; - case TweenAction.CANVAS_COLOR: - this.uiImage = trans.gameObject.GetComponent(); - if(this.uiImage != null) - this.setFromColor( this.uiImage.color ); - break; - case TweenAction.TEXT_ALPHA: - this.uiText = trans.gameObject.GetComponent(); - if (this.uiText != null) - this.from.x = this.uiText.color.a; - break; - case TweenAction.TEXT_COLOR: - this.uiText = trans.gameObject.GetComponent(); - if (this.uiText != null) - this.setFromColor( this.uiText.color ); - break; - case TweenAction.CANVAS_MOVE: - this.from = this.rectTransform.anchoredPosition3D; break; - case TweenAction.CANVAS_MOVE_X: - this.from.x = this.rectTransform.anchoredPosition3D.x; break; - case TweenAction.CANVAS_MOVE_Y: - this.from.x = this.rectTransform.anchoredPosition3D.y; break; - case TweenAction.CANVAS_MOVE_Z: - this.from.x = this.rectTransform.anchoredPosition3D.z; break; - case TweenAction.CANVAS_ROTATEAROUND: - case TweenAction.CANVAS_ROTATEAROUND_LOCAL: - this.lastVal = 0.0f; - this.from.x = 0.0f; - this.origRotation = this.rectTransform.rotation; - break; - case TweenAction.CANVAS_SCALE: - this.from = this.rectTransform.localScale; break; - case TweenAction.CANVAS_PLAYSPRITE: - this.uiImage = trans.gameObject.GetComponent(); - this.from.x = 0f; - break; - #endif - } - if(this.type!=TweenAction.CALLBACK_COLOR && this.type!=TweenAction.COLOR && this.type!=TweenAction.TEXT_COLOR && this.type!=TweenAction.CANVAS_COLOR) - this.diff = this.to - this.from; - if(this.onCompleteOnStart){ - if(this.onComplete!=null){ - this.onComplete(); - }else if(this.onCompleteObject!=null){ - this.onCompleteObject(this.onCompleteParam); - } - } - } - - public LTDescr setFromColor( Color col ){ - this.from = new Vector3(0.0f, col.a, 0.0f); - this.diff = new Vector3(1.0f,0.0f,0.0f); - this.axis = new Vector3( col.r, col.g, col.b ); - return this; - } - - /** - * Pause a tween - * - * @method pause - * @return {LTDescr} LTDescr an object that distinguishes the tween - */ - public LTDescr pause(){ - if(this.direction != 0.0f){ // check if tween is already paused - this.directionLast = this.direction; - this.direction = 0.0f; - } + public static bool throwErrors = true; + public static float tau = Mathf.PI*2.0f; + public static float PI_DIV2 = Mathf.PI / 2.0f; + + private static LTSeq[] sequences; + + private static LTDescr[] tweens; + private static int[] tweensFinished; + private static int[] tweensFinishedIds; + private static LTDescr tween; + private static int tweenMaxSearch = -1; + private static int maxTweens = 400; + private static int maxSequences = 400; + private static int frameRendered= -1; + private static GameObject _tweenEmpty; + public static float dtEstimated = -1f; + public static float dtManual; + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 + private static float previousRealTime; + #endif + public static float dtActual; + private static uint global_counter = 0; + private static int i; + private static int j; + private static int finishedCnt; + public static AnimationCurve punch = new AnimationCurve( new Keyframe(0.0f, 0.0f ), new Keyframe(0.112586f, 0.9976035f ), new Keyframe(0.3120486f, -0.1720615f ), new Keyframe(0.4316337f, 0.07030682f ), new Keyframe(0.5524869f, -0.03141804f ), new Keyframe(0.6549395f, 0.003909959f ), new Keyframe(0.770987f, -0.009817753f ), new Keyframe(0.8838775f, 0.001939224f ), new Keyframe(1.0f, 0.0f ) ); + public static AnimationCurve shake = new AnimationCurve( new Keyframe(0f, 0f), new Keyframe(0.25f, 1f), new Keyframe(0.75f, -1f), new Keyframe(1f, 0f) ) ; + + public static void init(){ + init(maxTweens); + } - return this; - } - - /** - * Resume a paused tween - * - * @method resume - * @return {LTDescr} LTDescr an object that distinguishes the tween - */ - public LTDescr resume(){ - this.direction = this.directionLast; - return this; - } - - public LTDescr setAxis( Vector3 axis ){ - this.axis = axis; - return this; - } - - /** - * Delay the start of a tween - * - * @method setDelay - * @param {float} float time The time to complete the tween in - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setDelay( 1.5f ); - */ - public LTDescr setDelay( float delay ){ - if(this.useEstimatedTime){ - this.delay = delay; - }else{ - this.delay = delay;//*Time.timeScale; - } - - return this; - } - - /** - * Set the type of easing used for the tween.
- * - * - * @method setEase - * @param {LeanTweenType} easeType:LeanTweenType the easing type to use - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); - */ - public LTDescr setEase( LeanTweenType easeType ){ - this.tweenType = easeType; - return this; - } - - /** - * Set how far past a tween will overshoot for certain ease types (compatible: easeInBack, easeInOutBack, easeOutBack, easeOutElastic, easeInElastic, easeInOutElastic).
- * @method setOvershoot - * @param {float} overshoot:float how far past the destination it will go before settling in - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutBack ).setOvershoot(2f); - */ - public LTDescr setOvershoot( float overshoot ){ - this.overshoot = overshoot; - return this; - } - - /** - * Set how short the iterations are for certain ease types (compatible: easeOutElastic, easeInElastic, easeInOutElastic).
- * @method setPeriod - * @param {float} period:float how short the iterations are that the tween will animate at (default 0.3f) - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeOutElastic ).setPeriod(0.3f); - */ - public LTDescr setPeriod( float period ){ - this.period = period; - return this; - } - - /** - * Set the type of easing used for the tween with a custom curve.
- * @method setEase (AnimationCurve) - * @param {AnimationCurve} easeDefinition:AnimationCurve an AnimationCure that describes the type of easing you want, this is great for when you want a unique type of movement - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setEase( LeanTweenType.easeInBounce ); - */ - public LTDescr setEase( AnimationCurve easeCurve ){ - this.animationCurve = easeCurve; - return this; - } - - /** - * Set the end that the GameObject is tweening towards - * @method setTo - * @param {Vector3} to:Vector3 point at which you want the tween to reach - * @return {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); );
- */ - public LTDescr setTo( Vector3 to ){ - if(this.hasInitiliazed){ - this.to = to; - this.diff = to - this.from; - }else{ - this.to = to; - } - - return this; - } - - public LTDescr setFrom( Vector3 from ){ - if(this.trans) - this.init(); - this.from = from; - // this.hasInitiliazed = true; // this is set, so that the "from" value isn't overwritten later on when the tween starts - this.diff = this.to - this.from; - return this; - } - - public LTDescr setFrom( float from ){ - return setFrom( new Vector3(from, 0f, 0f) ); - } - - public LTDescr setDiff( Vector3 diff ){ - this.diff = diff; - return this; - } - - public LTDescr setHasInitialized( bool has ){ - this.hasInitiliazed = has; - return this; - } - - public LTDescr setId( uint id ){ - this._id = id; - this.counter = global_counter; - // Debug.Log("Global counter:"+global_counter); - return this; - } - - /** - * Set the finish time of the tween - * @method setTime - * @param {float} finishTime:float the length of time in seconds you wish the tween to complete in - * @return {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 );
- */ - public LTDescr setTime( float time ){ - this.time = time; - return this; - } - - /** - * Set the tween to repeat a number of times. - * @method setRepeat - * @param {int} repeatNum:int the number of times to repeat the tween. -1 to repeat infinite times - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 10 ).setLoopPingPong(); - */ - public LTDescr setRepeat( int repeat ){ - this.loopCount = repeat; - if((repeat>1 && this.loopType == LeanTweenType.once) || (repeat < 0 && this.loopType == LeanTweenType.once)){ - this.loopType = LeanTweenType.clamp; - } - if(this.type==TweenAction.CALLBACK || this.type==TweenAction.CALLBACK_COLOR){ - this.setOnCompleteOnRepeat(true); - } - return this; - } - - public LTDescr setLoopType( LeanTweenType loopType ){ - this.loopType = loopType; - return this; - } - - public LTDescr setUseEstimatedTime( bool useEstimatedTime ){ - this.useEstimatedTime = useEstimatedTime; - return this; - } - - /** - * 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) - * @method setIgnoreTimeScale - * @param {bool} useUnScaledTime:bool whether to use the unscaled time or not - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setIgnoreTimeScale( true ); - */ - public LTDescr setIgnoreTimeScale( bool useUnScaledTime ){ - this.useEstimatedTime = useUnScaledTime; - return this; - } - - /** - * Use frames when tweening an object, when you don't want the animation to be time-frame independent... - * @method setUseFrames - * @param {bool} useFrames:bool whether to use estimated time or not - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setRepeat( 2 ).setUseFrames( true ); - */ - public LTDescr setUseFrames( bool useFrames ){ - this.useFrames = useFrames; - return this; - } - - public LTDescr setUseManualTime( bool useManualTime ){ - this.useManualTime = useManualTime; - return this; - } - - public LTDescr setLoopCount( int loopCount ){ - this.loopCount = loopCount; - return this; - } - - /** - * No looping involved, just run once (the default) - * @method setLoopOnce - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopOnce(); - */ - public LTDescr setLoopOnce(){ this.loopType = LeanTweenType.once; return this; } - - /** - * When the animation gets to the end it starts back at where it began - * @method setLoopClamp - * @param {int} loops:int (defaults to -1) how many times you want the loop to happen (-1 for an infinite number of times) - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopClamp( 2 ); - */ - public LTDescr setLoopClamp(){ - this.loopType = LeanTweenType.clamp; - if(this.loopCount==0) - this.loopCount = -1; - return this; - } - public LTDescr setLoopClamp( int loops ){ - this.loopCount = loops; - return this; - } - - /** - * When the animation gets to the end it then tweens back to where it started (and on, and on) - * @method setLoopPingPong - * @param {int} loops: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. - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setLoopPingPong( 2 ); - */ - public LTDescr setLoopPingPong(){ - this.loopType = LeanTweenType.pingPong; - if(this.loopCount==0) - this.loopCount = -1; - return this; - } - public LTDescr setLoopPingPong( int loops ) { - this.loopType = LeanTweenType.pingPong; - this.loopCount = loops == -1 ? loops : loops * 2; - return this; - } - - /** - * Have a method called when the tween finishes - * @method setOnComplete - * @param {Action} onComplete:Action the method that should be called when the tween is finished ex: tweenFinished(){ } - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished ); - */ - public LTDescr setOnComplete( Action onComplete ){ - this.onComplete = onComplete; - return this; - } - - /** - * Have a method called when the tween finishes - * @method setOnComplete (object) - * @param {Action} onComplete:Action the method that should be called when the tween is finished ex: tweenFinished( object myObj ){ } - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnComplete( tweenFinished ); - */ - public LTDescr setOnComplete( Action onComplete ){ - this.onCompleteObject = onComplete; - return this; - } - public LTDescr setOnComplete( Action onComplete, object onCompleteParam ){ - this.onCompleteObject = onComplete; - if(onCompleteParam!=null) - this.onCompleteParam = onCompleteParam; - return this; - } - - /** - * Pass an object to along with the onComplete Function - * @method setOnCompleteParam - * @param {object} onComplete:object an object that - * @return {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]);
- * }
- */ - public LTDescr setOnCompleteParam( object onCompleteParam ){ - this.onCompleteParam = onCompleteParam; - return this; - } - - - /** - * Have a method called on each frame that the tween is being animated (passes a float value) - * @method setOnUpdate - * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
- *
- * void tweenMoved( float val ){ }
- */ - public LTDescr setOnUpdate( Action onUpdate ){ - this.onUpdateFloat = onUpdate; - this.hasUpdateCallback = true; - return this; - } - public LTDescr setOnUpdateRatio(Action onUpdate) - { - this.onUpdateFloatRatio = onUpdate; - this.hasUpdateCallback = true; - return this; + public static int maxSearch{ + get{ + return tweenMaxSearch; + } } - - public LTDescr setOnUpdateObject( Action onUpdate ){ - this.onUpdateFloatObject = onUpdate; - this.hasUpdateCallback = true; - return this; - } - public LTDescr setOnUpdateVector2( Action onUpdate ){ - this.onUpdateVector2 = onUpdate; - this.hasUpdateCallback = true; - return this; - } - public LTDescr setOnUpdateVector3( Action onUpdate ){ - this.onUpdateVector3 = onUpdate; - this.hasUpdateCallback = true; - return this; - } - public LTDescr setOnUpdateColor( Action onUpdate ){ - this.onUpdateColor = onUpdate; - this.hasUpdateCallback = true; - return this; - } - - #if !UNITY_FLASH - - public LTDescr setOnUpdate( Action onUpdate ){ - this.onUpdateColor = onUpdate; - this.hasUpdateCallback = true; - return this; - } - - /** - * Have a method called on each frame that the tween is being animated (passes a float value and a object) - * @method setOnUpdate (object) - * @param {Action} onUpdate: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 - * @return {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 ){ }
- */ - public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ - this.onUpdateFloatObject = onUpdate; - this.hasUpdateCallback = true; - if(onUpdateParam!=null) - this.onUpdateParam = onUpdateParam; - return this; - } - - public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ - this.onUpdateVector3Object = onUpdate; - this.hasUpdateCallback = true; - if(onUpdateParam!=null) - this.onUpdateParam = onUpdateParam; - return this; - } - - public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ - this.onUpdateVector2 = onUpdate; - this.hasUpdateCallback = true; - if(onUpdateParam!=null) - this.onUpdateParam = onUpdateParam; - return this; - } - - /** - * Have a method called on each frame that the tween is being animated (passes a float value) - * @method setOnUpdate (Vector3) - * @param {Action} onUpdate:Action a method that will be called on every frame with the float value of the tweened object - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.moveX(gameObject, 5f, 2.0f ).setOnUpdate( tweenMoved );
- *
- * void tweenMoved( Vector3 val ){ }
- */ - public LTDescr setOnUpdate( Action onUpdate, object onUpdateParam = null ){ - this.onUpdateVector3 = onUpdate; - this.hasUpdateCallback = true; - if(onUpdateParam!=null) - this.onUpdateParam = onUpdateParam; - return this; - } - #endif - - - /** - * Have an object passed along with the onUpdate method - * @method setOnUpdateParam - * @param {object} onUpdateParam:object an object that will be passed along with the onUpdate method - * @return {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 ){ }
- */ - public LTDescr setOnUpdateParam( object onUpdateParam ){ - this.onUpdateParam = onUpdateParam; - return this; - } - - /** - * While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon - * @method setOrientToPath - * @param {bool} doesOrient:bool whether the gameobject will orient to the path it is animating along - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);
- */ - public LTDescr setOrientToPath( bool doesOrient ){ - if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ - if(this.path==null) - this.path = new LTBezierPath(); - this.path.orientToPath = doesOrient; - }else{ - this.spline.orientToPath = doesOrient; - } - return this; - } - - /** - * While tweening along a curve, set this property to true, to be perpendicalur to the path it is moving upon - * @method setOrientToPath2d - * @param {bool} doesOrient:bool whether the gameobject will orient to the path it is animating along - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.move( ltLogo, path, 1.0f ).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true).setAxis(Vector3.forward);
- */ - public LTDescr setOrientToPath2d( bool doesOrient2d ){ - setOrientToPath(doesOrient2d); - if(this.type==TweenAction.MOVE_CURVED || this.type==TweenAction.MOVE_CURVED_LOCAL){ - this.path.orientToPath2d = doesOrient2d; - }else{ - this.spline.orientToPath2d = doesOrient2d; - } - return this; - } - - public LTDescr setRect( LTRect rect ){ - this.ltRect = rect; - return this; - } - - public LTDescr setRect( Rect rect ){ - this.ltRect = new LTRect(rect); - return this; - } - - public LTDescr setPath( LTBezierPath path ){ - this.path = path; - return this; - } - - /** - * Set the point at which the GameObject will be rotated around - * @method setPoint - * @param {Vector3} point:Vector3 point at which you want the object to rotate around (local space) - * @return {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 );
- */ - public LTDescr setPoint( Vector3 point ){ - this.point = point; - return this; - } - - public LTDescr setDestroyOnComplete( bool doesDestroy ){ - this.destroyOnComplete = doesDestroy; - return this; - } - - public LTDescr setAudio( object audio ){ - this.onCompleteParam = audio; - return this; - } - - /** - * Set the onComplete method to be called at the end of every loop cycle (also applies to the delayedCall method) - * @method setOnCompleteOnRepeat - * @param {bool} isOn:bool does call onComplete on every loop cycle - * @return {LTDescr} LTDescr an object that distinguishes the tween - * @example - * LeanTween.delayedCall(gameObject,0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true); - */ - public LTDescr setOnCompleteOnRepeat( bool isOn ){ - this.onCompleteOnRepeat = isOn; - return this; - } - - /** - * Set the onComplete method to be called at the beginning of the tween (it will still be called when it is completed as well) - * @method setOnCompleteOnStart - * @param {bool} isOn:bool does call onComplete at the start of the tween - * @return {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);
- */ - public LTDescr setOnCompleteOnStart( bool isOn ){ - this.onCompleteOnStart = isOn; - return this; - } - -#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 - public LTDescr setRect( RectTransform rect ){ - this.rectTransform = rect; - return this; - } - - public LTDescr setSprites( UnityEngine.Sprite[] sprites ){ - this.sprites = sprites; - return this; - } - - public LTDescr setFrameRate( float frameRate ){ - this.time = this.sprites.Length / frameRate; - return this; - } -#endif - - /** - * Have a method called when the tween starts - * @method setOnStart () - * @param {Action<>} onStart:Action<> the method that should be called when the tween is starting ex: tweenStarted( ){ } - * @return {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!"); } ); - */ - public LTDescr setOnStart( Action onStart ){ - this.onStart = onStart; - return this; + + public static int maxSimulataneousTweens{ + get { + return maxTweens; + } } /** - * Set the direction of a tween -1f for backwards 1f for forwards (currently only bezier and spline paths are supported) - * @method setDirection () - * @param {float} direction:float the direction that the tween should run, -1f for backwards 1f for forwards - * @return {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);
- */ - - public LTDescr setDirection( float direction ){ - if(this.direction!=-1f && this.direction!=1f){ - Debug.LogWarning("You have passed an incorrect direction of '"+direction+"', direction must be -1f or 1f"); - return this; - } - - if(this.direction!=direction){ - // Debug.Log("reverse path:"+this.path+" spline:"+this.spline); - if(this.path!=null){ - this.path = new LTBezierPath( LTUtility.reverse( this.path.pts ) ); - }else if(this.spline!=null){ - this.spline = new LTSpline( LTUtility.reverse( this.spline.pts ) ); - } - } - - return this; + * Find out how many tweens you have animating at a given time Find out how many tweens you have animating at a given time + * + * @method LeanTween.tweensRunning + * @example + * Debug.Log("I have "+LeanTween.tweensRunning+" animating!"); + */ + public static int tweensRunning{ + get{ + int count = 0; + for (int i = 0; i <= tweenMaxSearch; i++){ + if (tweens[i].toggle){ + count++; + } + } + return count; + } } -} - -public class LTUtility { + /** + * This line is optional. Here you can specify the maximum number of tweens you will use (the default is 400). This must be called before any use of LeanTween is made for it to be effective. This line is optional. Here you can specify the maximum number of tweens you will use (the default is 400). This must be called before any use of LeanTween is made for it to be effective. + * + * @method LeanTween.init + * @param {integer} maxSimultaneousTweens:int The maximum number of tweens you will use, make sure you don't go over this limit, otherwise the code will throw an error + * @example + * LeanTween.init( 800 ); + */ + public static void init(int maxSimultaneousTweens ){ + init(maxSimultaneousTweens, maxSequences); + } + + public static void init(int maxSimultaneousTweens, int maxSimultaneousSequences){ + if(tweens==null){ + maxTweens = maxSimultaneousTweens; + tweens = new LTDescr[maxTweens]; + tweensFinished = new int[maxTweens]; + tweensFinishedIds = new int[maxTweens]; + _tweenEmpty = new GameObject(); + _tweenEmpty.name = "~LeanTween"; + _tweenEmpty.AddComponent(typeof(LeanTween)); + _tweenEmpty.isStatic = true; + #if !UNITY_EDITOR + _tweenEmpty.hideFlags = HideFlags.HideAndDontSave; + #endif + #if UNITY_EDITOR + if(Application.isPlaying) + DontDestroyOnLoad( _tweenEmpty ); + #else + DontDestroyOnLoad( _tweenEmpty ); + #endif + for(int i = 0; i < maxTweens; i++){ + tweens[i] = new LTDescr(); + } - public static Vector3[] reverse( Vector3[] arr ){ - - int k = arr.Length - 1; - for(int i=0;i<=(arr.Length/2);i++) - { - Vector3 temp = arr[i]; - arr[i]=arr[k]; - arr[k]=temp; - k--; - } + #if UNITY_5_4_OR_NEWER + UnityEngine.SceneManagement.SceneManager.sceneLoaded += onLevelWasLoaded54; + #endif - return arr; - } -} + sequences = new LTSeq[ maxSimultaneousSequences ]; -/** -* LeanTween is an efficient tweening engine for Unity3d

-* Index of All Methods | Optional Paramaters that can be passed

-* 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 modify this tween later, just save the unique id of the tween.
-*

Example:

-* int id = LeanTween.moveX(gameObject, 1f, 1f).id;
-* LTDescr d = LeanTween.descr( id );

-* if(d!=null){ // if the tween has already finished it will return null
-*    // change some parameters
-*    d.setOnComplete( onCompleteFunc ).setEase( LeanTweenType.easeInOutBack );
-* } -* -* @class LeanTween -*/ + for(int i = 0; i < maxSimultaneousSequences; i++){ + sequences[i] = new LTSeq(); + } + } + } -public class LeanTween : MonoBehaviour { + public static void reset(){ + if(tweens!=null){ + for (int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i]!=null) + tweens[i].toggle = false; + } + } + tweens = null; + Destroy(_tweenEmpty); + } -public static bool throwErrors = true; -public static float tau = Mathf.PI*2.0f; - -private static LTDescr[] tweens; -private static int[] tweensFinished; -private static LTDescr tween; -private static int tweenMaxSearch = -1; -private static int maxTweens = 400; -private static int frameRendered= -1; -private static GameObject _tweenEmpty; -private static float dtEstimated = -1f; -public static float dtManual; -#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 -private static float previousRealTime; -#endif -private static float dt; -private static float dtActual; -private static int i; -private static int j; -private static int finishedCnt; -private static AnimationCurve punch = new AnimationCurve( new Keyframe(0.0f, 0.0f ), new Keyframe(0.112586f, 0.9976035f ), new Keyframe(0.3120486f, -0.1720615f ), new Keyframe(0.4316337f, 0.07030682f ), new Keyframe(0.5524869f, -0.03141804f ), new Keyframe(0.6549395f, 0.003909959f ), new Keyframe(0.770987f, -0.009817753f ), new Keyframe(0.8838775f, 0.001939224f ), new Keyframe(1.0f, 0.0f ) ); -private static AnimationCurve shake = new AnimationCurve( new Keyframe(0f, 0f), new Keyframe(0.25f, 1f), new Keyframe(0.75f, -1f), new Keyframe(1f, 0f) ) ; - -public static void init(){ - init(maxTweens); -} + public void Update(){ + LeanTween.update(); + } -public static int maxSearch{ - get{ - return tweenMaxSearch; - } -} + #if UNITY_5_4_OR_NEWER + private static void onLevelWasLoaded54( UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode ){ internalOnLevelWasLoaded( scene.buildIndex ); } + #else + public void OnLevelWasLoaded( int lvl ){ internalOnLevelWasLoaded( lvl ); } + #endif -public static int tweensRunning{ - get{ - int count = 0; - for (int i = 0; i <= tweenMaxSearch; i++){ - if (tweens[i].toggle){ - count++; - } - } - return count; - } -} + private static void internalOnLevelWasLoaded( int lvl ){ + // Debug.Log("reseting gui"); + LTGUI.reset(); + } -/** -* This line is optional. Here you can specify the maximum number of tweens you will use (the default is 400). This must be called before any use of LeanTween is made for it to be effective. -* -* @method LeanTween.init -* @param {integer} maxSimultaneousTweens:int The maximum number of tweens you will use, make sure you don't go over this limit, otherwise the code will throw an error -* @example -* LeanTween.init( 800 ); -*/ -public static void init(int maxSimultaneousTweens){ - if(tweens==null){ - maxTweens = maxSimultaneousTweens; - tweens = new LTDescr[maxTweens]; - tweensFinished = new int[maxTweens]; - _tweenEmpty = new GameObject(); - _tweenEmpty.name = "~LeanTween"; - _tweenEmpty.AddComponent(typeof(LeanTween)); - _tweenEmpty.isStatic = true; - #if !UNITY_EDITOR - _tweenEmpty.hideFlags = HideFlags.HideAndDontSave; - #endif - DontDestroyOnLoad( _tweenEmpty ); - for(int i = 0; i < maxTweens; i++){ - tweens[i] = new LTDescr(); - } - } -} + private static int maxTweenReached; + + public static void update() { + if(frameRendered != Time.frameCount){ // make sure update is only called once per frame + init(); + + #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 + dtEstimated = Time.realtimeSinceStartup - previousRealTime; + if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large + dtEstimated = 0.2f; + previousRealTime = Time.realtimeSinceStartup; + #else + + dtEstimated = dtEstimated<0f ? 0f : dtEstimated = Time.unscaledDeltaTime; + + // Debug.Log("Time.unscaledDeltaTime:"+Time.unscaledDeltaTime); + #endif + + dtActual = Time.deltaTime; + maxTweenReached = 0; + finishedCnt = 0; + // if(tweenMaxSearch>1500) + // Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens); + for( int i = 0; i <= tweenMaxSearch && i < maxTweens; i++){ + tween = tweens[i]; +// if(i==0 && tweens[i].toggle) +// Debug.Log("tweens["+i+"]"+tweens[i]); + if(tween.toggle){ + maxTweenReached = i; + + if (tween.updateInternal()) { // returns true if the tween is finished with it's loop + tweensFinished[finishedCnt] = i; + tweensFinishedIds[finishedCnt] = tweens[i].id; + finishedCnt++; + } + } + } -public static void reset(){ - for (int i = 0; i <= tweenMaxSearch; i++){ - tweens[i].toggle = false; - } - tweens = null; - Destroy(_tweenEmpty); -} + // Debug.Log("maxTweenReached:"+maxTweenReached); + tweenMaxSearch = maxTweenReached; + frameRendered = Time.frameCount; -public void Update(){ - LeanTween.update(); -} + for(int i = 0; i < finishedCnt; i++){ + j = tweensFinished[i]; + tween = tweens[ j ]; -#if UNITY_5_4_OR_NEWER -protected void Awake() -{ - UnityEngine.SceneManagement.SceneManager.activeSceneChanged += (A, B) => { - LevelWasLoaded(); - }; -} -#else -protected void OnLevelWasLoaded(int level) -{ - LevelWasLoaded(); -} -#endif + if (tween.id == tweensFinishedIds[i]){ + // Debug.Log("removing tween:"+tween); + removeTween(j); + if(tween.hasExtraOnCompletes && tween.trans!=null) + tween.callOnCompletes(); + } + } -public void LevelWasLoaded(){ - // Debug.Log("reseting gui"); - LTGUI.reset(); -} + } + } -private static Transform trans; -private static float timeTotal; -private static TweenAction tweenAction; -private static float ratioPassed; -private static float from; -//private static float to = 1.0f; -private static float val; -private static bool isTweenFinished; -private static int maxTweenReached; -private static Vector3 newVect; -private static GameObject target; -private static GameObject customTarget; - -public static void update() { - if(frameRendered != Time.frameCount){ // make sure update is only called once per frame - init(); - - #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 - dtEstimated = Time.realtimeSinceStartup - previousRealTime; - if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large - dtEstimated = 0.2f; - previousRealTime = Time.realtimeSinceStartup; - #else - if(dtEstimated<0f){ - dtEstimated = 0f; - }else{ - dtEstimated = Time.unscaledDeltaTime; - } - // Debug.Log("Time.unscaledDeltaTime:"+Time.unscaledDeltaTime); - #endif - - dtActual = Time.deltaTime; - maxTweenReached = 0; - finishedCnt = 0; - // if(tweenMaxSearch>1500) - // Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens); - for( int i = 0; i <= tweenMaxSearch && i < maxTweens; i++){ - - //if(i==0 && tweens[i].toggle) - // Debug.Log("tweens["+i+"]"+tweens[i]+" dt:"+dt); - if(tweens[i].toggle){ - maxTweenReached = i; - tween = tweens[i]; - trans = tween.trans; - timeTotal = tween.time; - tweenAction = tween.type; - - /*if(trans.gameObject.name=="Main Camera"){ - Debug.Log("main tween:"+tween+" i:"+i); - }*/ - - if( tween.useEstimatedTime ){ - dt = dtEstimated; - }else if( tween.useFrames ){ - dt = 1; - }else if( tween.useManualTime ){ - dt = dtManual; - }else if(tween.direction==0f){ - dt = 0f; - }else{ - dt = dtActual; - } - - if(trans==null){ - removeTween(i); - continue; - } - // Debug.Log("i:"+i+" tween:"+tween+" dt:"+dt); - - // Check for tween finished - isTweenFinished = false; - if(tween.delay<=0){ - if((tween.passed + dt > tween.time && tween.direction > 0.0f )){ - // Debug.Log("i:"+i+" passed:"+tween.passed+" dt:"+dt+" time:"+tween.time+" dir:"+tween.direction); - isTweenFinished = true; - tween.passed = tween.time; // Set to the exact end time so that it can finish tween exactly on the end value - }else if(tween.direction<0.0f && tween.passed - dt < 0.0f){ - isTweenFinished = true; - tween.passed = Mathf.Epsilon; - } - } - - if(!tween.hasInitiliazed && ((tween.passed==0.0 && tween.delay==0.0) || tween.passed>0.0) ){ - tween.init(); - } - - if(tween.delay<=0){ - // Move Values - if(timeTotal<=0f){ - //Debug.LogError("time total is zero Time.timeScale:"+Time.timeScale+" useEstimatedTime:"+tween.useEstimatedTime); - ratioPassed = 1f; - }else{ - ratioPassed = tween.passed / timeTotal; - } - - if(ratioPassed>1.0f){ - ratioPassed = 1.0f; - }else if(ratioPassed<0f){ - ratioPassed = 0f; - } - // Debug.Log("action:"+tweenAction+" ratioPassed:"+ratioPassed + " timeTotal:" + timeTotal + " tween.passed:"+ tween.passed +" dt:"+dt); - - if(tweenAction>=TweenAction.MOVE_X && tweenAction0){ - foreach (Transform child in trans) { - if(child.gameObject.renderer!=null){ - foreach(Material mat in child.gameObject.renderer.materials){ - mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val); - } - } - } - } - - #else - - SpriteRenderer ren = trans.gameObject.GetComponent(); - - if(ren!=null){ - ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val); - }else{ - if(trans.gameObject.GetComponent()!=null){ - foreach(Material mat in trans.gameObject.GetComponent().materials){ - if(mat.HasProperty("_Color")){ - mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val); - }else if(mat.HasProperty("_TintColor")){ - Color col = mat.GetColor ("_TintColor"); - mat.SetColor("_TintColor", new Color( col.r, col.g, col.b, val)); - } - } - } - if(trans.childCount>0){ - foreach (Transform child in trans) { - if(child.gameObject.GetComponent()!=null){ - foreach(Material mat in child.gameObject.GetComponent().materials){ - mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val); - } - } - } - } - } - - #endif - }else if(tweenAction==TweenAction.ALPHA_VERTEX){ - Mesh mesh = trans.GetComponent().mesh; - Vector3[] vertices = mesh.vertices; - Color32[] colors = new Color32[vertices.Length]; - Color32 c = mesh.colors32[0]; - c = new Color( c.r, c.g, c.b, val); - for (int k= 0; k < vertices.Length; k++) { - colors[k] = c; - } - mesh.colors32 = colors; - }else if(tweenAction==TweenAction.COLOR || tweenAction==TweenAction.CALLBACK_COLOR){ - Color toColor = tweenColor(tween, val); - - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 - SpriteRenderer ren = trans.gameObject.GetComponent(); - if(ren!=null){ - ren.color = toColor; - }else{ - #endif - // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff); - if(tweenAction==TweenAction.COLOR){ - if(trans.gameObject.GetComponent()!=null){ - foreach(Material mat in trans.gameObject.GetComponent().materials){ - mat.color = toColor; - } - } - if(trans.childCount>0){ - foreach (Transform child in trans) { - if(child.gameObject.GetComponent()!=null){ - foreach(Material mat in child.gameObject.GetComponent().materials){ - mat.color = toColor; - } - } - } - } - } - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 - } - #endif - if(dt!=0f && tween.onUpdateColor!=null){ - tween.onUpdateColor(toColor); - } - } - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 - else if (tweenAction == TweenAction.CANVAS_ALPHA){ - Color c = tween.uiImage.color; - c.a = val; - tween.uiImage.color = c; - } - else if (tweenAction == TweenAction.CANVAS_COLOR){ - Color toColor = tweenColor(tween, val); - tween.uiImage.color = toColor; - if (dt!=0f && tween.onUpdateColor != null){ - tween.onUpdateColor(toColor); - } - } - else if (tweenAction == TweenAction.TEXT_ALPHA){ - textAlphaRecursive( trans, val ); - } - else if (tweenAction == TweenAction.TEXT_COLOR){ - Color toColor = tweenColor(tween, val); - tween.uiText.color = toColor; - if (dt!=0f && tween.onUpdateColor != null){ - tween.onUpdateColor(toColor); - } - if(trans.childCount>0){ - foreach (Transform child in trans) { - UnityEngine.UI.Text uiText = child.gameObject.GetComponent(); - if(uiText!=null){ - uiText.color = toColor; - } - } - } - } - else if(tweenAction==TweenAction.CANVAS_ROTATEAROUND){ - // figure out how much the rotation has shifted the object over - RectTransform rect = tween.rectTransform; - Vector3 origPos = rect.localPosition; - rect.RotateAround((Vector3)rect.TransformPoint( tween.point ), tween.axis, -val); - Vector3 diff = origPos - rect.localPosition; - - rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position - rect.rotation = tween.origRotation; - rect.RotateAround((Vector3)rect.TransformPoint( tween.point ), tween.axis, val); - }else if(tweenAction==TweenAction.CANVAS_ROTATEAROUND_LOCAL){ - // figure out how much the rotation has shifted the object over - RectTransform rect = tween.rectTransform; - Vector3 origPos = rect.localPosition; - rect.RotateAround((Vector3)rect.TransformPoint( tween.point ), rect.TransformDirection(tween.axis), -val); - Vector3 diff = origPos - rect.localPosition; - - rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position - rect.rotation = tween.origRotation; - rect.RotateAround((Vector3)rect.TransformPoint( tween.point ), rect.TransformDirection(tween.axis), val); - }else if(tweenAction==TweenAction.CANVAS_PLAYSPRITE){ - int frame = (int)Mathf.Round( val ); - // Debug.Log("frame:"+frame+" val:"+val); - tween.uiImage.sprite = tween.sprites[ frame ]; - }else if(tweenAction==TweenAction.CANVAS_MOVE_X){ - Vector3 current = tween.rectTransform.anchoredPosition3D; - tween.rectTransform.anchoredPosition3D = new Vector3(val, current.y, current.z); - }else if(tweenAction==TweenAction.CANVAS_MOVE_Y){ - Vector3 current = tween.rectTransform.anchoredPosition3D; - tween.rectTransform.anchoredPosition3D = new Vector3(current.x, val, current.z); - }else if(tweenAction==TweenAction.CANVAS_MOVE_Z){ - Vector3 current = tween.rectTransform.anchoredPosition3D; - tween.rectTransform.anchoredPosition3D = new Vector3(current.x, current.y, val); - } - #endif - - }else if(tweenAction>=TweenAction.MOVE){ - // - - if(tween.animationCurve!=null){ - newVect = tweenOnCurveVector(tween, ratioPassed); - }else{ - if(tween.tweenType == LeanTweenType.linear){ - newVect = new Vector3( tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed); - }else if(tween.tweenType >= LeanTweenType.linear){ - switch(tween.tweenType){ - case LeanTweenType.easeOutQuad: - newVect = new Vector3(easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break; - case LeanTweenType.easeInQuad: - newVect = new Vector3(easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break; - case LeanTweenType.easeInOutQuad: - newVect = new Vector3(easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break; - case LeanTweenType.easeInCubic: - newVect = new Vector3(easeInCubic(tween.from.x, tween.to.x, ratioPassed), easeInCubic(tween.from.y, tween.to.y, ratioPassed), easeInCubic(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutCubic: - newVect = new Vector3(easeOutCubic(tween.from.x, tween.to.x, ratioPassed), easeOutCubic(tween.from.y, tween.to.y, ratioPassed), easeOutCubic(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutCubic: - newVect = new Vector3(easeInOutCubic(tween.from.x, tween.to.x, ratioPassed), easeInOutCubic(tween.from.y, tween.to.y, ratioPassed), easeInOutCubic(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInQuart: - newVect = new Vector3(easeInQuart(tween.from.x, tween.to.x, ratioPassed), easeInQuart(tween.from.y, tween.to.y, ratioPassed), easeInQuart(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutQuart: - newVect = new Vector3(easeOutQuart(tween.from.x, tween.to.x, ratioPassed), easeOutQuart(tween.from.y, tween.to.y, ratioPassed), easeOutQuart(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutQuart: - newVect = new Vector3(easeInOutQuart(tween.from.x, tween.to.x, ratioPassed), easeInOutQuart(tween.from.y, tween.to.y, ratioPassed), easeInOutQuart(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInQuint: - newVect = new Vector3(easeInQuint(tween.from.x, tween.to.x, ratioPassed), easeInQuint(tween.from.y, tween.to.y, ratioPassed), easeInQuint(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutQuint: - newVect = new Vector3(easeOutQuint(tween.from.x, tween.to.x, ratioPassed), easeOutQuint(tween.from.y, tween.to.y, ratioPassed), easeOutQuint(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutQuint: - newVect = new Vector3(easeInOutQuint(tween.from.x, tween.to.x, ratioPassed), easeInOutQuint(tween.from.y, tween.to.y, ratioPassed), easeInOutQuint(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInSine: - newVect = new Vector3(easeInSine(tween.from.x, tween.to.x, ratioPassed), easeInSine(tween.from.y, tween.to.y, ratioPassed), easeInSine(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutSine: - newVect = new Vector3(easeOutSine(tween.from.x, tween.to.x, ratioPassed), easeOutSine(tween.from.y, tween.to.y, ratioPassed), easeOutSine(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutSine: - newVect = new Vector3(easeInOutSine(tween.from.x, tween.to.x, ratioPassed), easeInOutSine(tween.from.y, tween.to.y, ratioPassed), easeInOutSine(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInExpo: - newVect = new Vector3(easeInExpo(tween.from.x, tween.to.x, ratioPassed), easeInExpo(tween.from.y, tween.to.y, ratioPassed), easeInExpo(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutExpo: - newVect = new Vector3(easeOutExpo(tween.from.x, tween.to.x, ratioPassed), easeOutExpo(tween.from.y, tween.to.y, ratioPassed), easeOutExpo(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutExpo: - newVect = new Vector3(easeInOutExpo(tween.from.x, tween.to.x, ratioPassed), easeInOutExpo(tween.from.y, tween.to.y, ratioPassed), easeInOutExpo(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInCirc: - newVect = new Vector3(easeInCirc(tween.from.x, tween.to.x, ratioPassed), easeInCirc(tween.from.y, tween.to.y, ratioPassed), easeInCirc(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutCirc: - newVect = new Vector3(easeOutCirc(tween.from.x, tween.to.x, ratioPassed), easeOutCirc(tween.from.y, tween.to.y, ratioPassed), easeOutCirc(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutCirc: - newVect = new Vector3(easeInOutCirc(tween.from.x, tween.to.x, ratioPassed), easeInOutCirc(tween.from.y, tween.to.y, ratioPassed), easeInOutCirc(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInBounce: - newVect = new Vector3(easeInBounce(tween.from.x, tween.to.x, ratioPassed), easeInBounce(tween.from.y, tween.to.y, ratioPassed), easeInBounce(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutBounce: - newVect = new Vector3(easeOutBounce(tween.from.x, tween.to.x, ratioPassed), easeOutBounce(tween.from.y, tween.to.y, ratioPassed), easeOutBounce(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInOutBounce: - newVect = new Vector3(easeInOutBounce(tween.from.x, tween.to.x, ratioPassed), easeInOutBounce(tween.from.y, tween.to.y, ratioPassed), easeInOutBounce(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeInBack: - newVect = new Vector3(easeInBack(tween.from.x, tween.to.x, ratioPassed), easeInBack(tween.from.y, tween.to.y, ratioPassed), easeInBack(tween.from.z, tween.to.z, ratioPassed)); break; - case LeanTweenType.easeOutBack: - newVect = new Vector3(easeOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot), easeOutBack(tween.from.y, tween.to.y, ratioPassed, tween.overshoot), easeOutBack(tween.from.z, tween.to.z, ratioPassed, tween.overshoot)); break; - case LeanTweenType.easeInOutBack: - newVect = new Vector3(easeInOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot), easeInOutBack(tween.from.y, tween.to.y, ratioPassed, tween.overshoot), easeInOutBack(tween.from.z, tween.to.z, ratioPassed, tween.overshoot)); break; - case LeanTweenType.easeInElastic: - newVect = new Vector3(easeInElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeInElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeInElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break; - case LeanTweenType.easeOutElastic: - newVect = new Vector3(easeOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeOutElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeOutElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break; - case LeanTweenType.easeInOutElastic: - newVect = new Vector3(easeInOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeInOutElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeInOutElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break; - case LeanTweenType.punch: - case LeanTweenType.easeShake: - if(tween.tweenType==LeanTweenType.punch){ - tween.animationCurve = LeanTween.punch; - }else if(tween.tweenType==LeanTweenType.easeShake){ - tween.animationCurve = LeanTween.shake; - } - tween.to = tween.from + tween.to; - tween.diff = tween.to - tween.from; - if(tweenAction==TweenAction.ROTATE || tweenAction==TweenAction.ROTATE_LOCAL){ - tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z)); - } - newVect = tweenOnCurveVector(tween, ratioPassed); break; - case LeanTweenType.easeSpring: - newVect = new Vector3(spring(tween.from.x, tween.to.x, ratioPassed), spring(tween.from.y, tween.to.y, ratioPassed), spring(tween.from.z, tween.to.z, ratioPassed)); break; - - } - }else{ - newVect = new Vector3( tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed); - } - } - - if(tweenAction==TweenAction.MOVE){ - trans.position = newVect; - }else if(tweenAction==TweenAction.MOVE_LOCAL){ - trans.localPosition = newVect; - }else if(tweenAction==TweenAction.ROTATE){ - /*if(tween.hasPhysics){ - trans.gameObject.rigidbody.MoveRotation(Quaternion.Euler( newVect )); - }else{*/ - trans.eulerAngles = newVect; - // } - }else if(tweenAction==TweenAction.ROTATE_LOCAL){ - trans.localEulerAngles = newVect; - }else if(tweenAction==TweenAction.SCALE){ - trans.localScale = newVect; - }else if(tweenAction==TweenAction.GUI_MOVE){ - tween.ltRect.rect = new Rect( newVect.x, newVect.y, tween.ltRect.rect.width, tween.ltRect.rect.height); - }else if(tweenAction==TweenAction.GUI_MOVE_MARGIN){ - tween.ltRect.margin = new Vector2(newVect.x, newVect.y); - }else if(tweenAction==TweenAction.GUI_SCALE){ - tween.ltRect.rect = new Rect( tween.ltRect.rect.x, tween.ltRect.rect.y, newVect.x, newVect.y); - }else if(tweenAction==TweenAction.GUI_ALPHA){ - tween.ltRect.alpha = newVect.x; - }else if(tweenAction==TweenAction.GUI_ROTATE){ - tween.ltRect.rotation = newVect.x; - } - #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 - else if(tweenAction==TweenAction.CANVAS_MOVE){ - tween.rectTransform.anchoredPosition3D = newVect; - }else if(tweenAction==TweenAction.CANVAS_SCALE){ - tween.rectTransform.localScale = newVect; - } - #endif - } - // Debug.Log("tween.delay:"+tween.delay + " tween.passed:"+tween.passed + " tweenAction:"+tweenAction + " to:"+newVect+" axis:"+tween.axis); - - if(dt!=0f && tween.hasUpdateCallback){ - if(tween.onUpdateFloat!=null){ - tween.onUpdateFloat(val); - } - if (tween.onUpdateFloatRatio != null){ - tween.onUpdateFloatRatio(val,ratioPassed); - }else if(tween.onUpdateFloatObject!=null){ - tween.onUpdateFloatObject(val, tween.onUpdateParam); - }else if(tween.onUpdateVector3Object!=null){ - tween.onUpdateVector3Object(newVect, tween.onUpdateParam); - }else if(tween.onUpdateVector3!=null){ - tween.onUpdateVector3(newVect); - }else if(tween.onUpdateVector2!=null){ - tween.onUpdateVector2(new Vector2(newVect.x,newVect.y)); - } - } - #if LEANTWEEN_1 - else if(tween.optional!=null){ // LeanTween 1.x legacy stuff - var onUpdate = tween.optional["onUpdate"]; - if(onUpdate!=null){ - Hashtable updateParam = (Hashtable)tween.optional["onUpdateParam"]; - if((TweenAction)tweenAction==TweenAction.VALUE3){ - if(onUpdate.GetType() == typeof(string)){ - string onUpdateS = onUpdate as string; - customTarget = tween.optional["onUpdateTarget"]!=null ? tween.optional["onUpdateTarget"] as GameObject : trans.gameObject; - customTarget.BroadcastMessage( onUpdateS, newVect ); - }else if(onUpdate.GetType() == typeof(System.Action)){ - System.Action onUpdateA = (System.Action)onUpdate; - onUpdateA(newVect, updateParam); - }else{ - System.Action onUpdateA = (System.Action)onUpdate; - onUpdateA(newVect); - } - }else{ - if(onUpdate.GetType() == typeof(string)){ - string onUpdateS = onUpdate as string; - if (tween.optional["onUpdateTarget"]!=null){ - customTarget = tween.optional["onUpdateTarget"] as GameObject; - customTarget.BroadcastMessage( onUpdateS, val ); - }else{ - trans.gameObject.BroadcastMessage( onUpdateS, val ); - } - }else if(onUpdate.GetType() == typeof(System.Action)){ - System.Action onUpdateA = (System.Action)onUpdate; - onUpdateA(val, updateParam); - }else if(onUpdate.GetType() == typeof(System.Action)){ - System.Action onUpdateA = (System.Action)onUpdate; - onUpdateA( newVect ); - }else{ - System.Action onUpdateA = (System.Action)onUpdate; - onUpdateA(val); - } - } - } - } - #endif - } - - if(isTweenFinished){ - if(tween.loopType==LeanTweenType.once || tween.loopCount==1){ - tweensFinished[finishedCnt] = i; - finishedCnt++; - - //Debug.Log("finished tween:"+i+" tween:"+tween); - if(tweenAction==TweenAction.GUI_ROTATE) - tween.ltRect.rotateFinished = true; - - if(tweenAction==TweenAction.DELAYED_SOUND){ - AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x); - } - }else{ - if((tween.loopCount<0 && tween.type==TweenAction.CALLBACK) || tween.onCompleteOnRepeat){ - if(tweenAction==TweenAction.DELAYED_SOUND){ - AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x); - } - if(tween.onComplete!=null){ - tween.onComplete(); - }else if(tween.onCompleteObject!=null){ - tween.onCompleteObject(tween.onCompleteParam); - } - } - if(tween.loopCount>=1){ - tween.loopCount--; - } - // Debug.Log("tween.loopType:"+tween.loopType+" tween.loopCount:"+tween.loopCount+" passed:"+tween.passed); - if(tween.loopType==LeanTweenType.pingPong){ - tween.direction = 0.0f-(tween.direction); - }else{ - tween.passed = Mathf.Epsilon; - } - } - }else if(tween.delay<=0f){ - tween.passed += dt*tween.direction; - }else{ - tween.delay -= dt; - // Debug.Log("dt:"+dt+" tween:"+i+" tween:"+tween); - if(tween.delay<0f){ - tween.passed = 0.0f;//-tween.delay - tween.delay = 0.0f; - } - } - } - } - - // Debug.Log("maxTweenReached:"+maxTweenReached); - tweenMaxSearch = maxTweenReached; - frameRendered = Time.frameCount; - - for(int i = 0; i < finishedCnt; i++){ - j = tweensFinished[i]; - tween = tweens[ j ]; - - // logError("removing tween:"+tween); - if(tween.onComplete!=null){ - System.Action onComplete = tween.onComplete; - //logError("removing tween for j:"+j+" tween:"+tween); - removeTween(j); - //tween.cleanup(); - onComplete(); - - }else if(tween.onCompleteObject!=null){ - System.Action onCompleteObject = tween.onCompleteObject; - object onCompleteParam = tween.onCompleteParam; - removeTween(j); - //tween.cleanup(); - onCompleteObject(onCompleteParam); - } - #if LEANTWEEN_1 - else if(tween.optional!=null){ - System.Action callback=null; - System.Action callbackWithParam = null; - string callbackS=string.Empty; - object callbackParam=null; - Hashtable optional = tween.optional; - if(tween.optional!=null && tween.trans){ - if(tween.optional["onComplete"]!=null){ - callbackParam = tween.optional["onCompleteParam"]; - if(tween.optional["onComplete"].GetType()==typeof(string)){ - callbackS = tween.optional["onComplete"] as string; - }else{ - if(callbackParam!=null){ - callbackWithParam = (System.Action)tween.optional["onComplete"]; - }else{ - callback = (System.Action)tween.optional["onComplete"]; - if(callback==null) - Debug.LogWarning("callback was not converted"); - } - } - } - } - removeTween(j); - if(callbackWithParam!=null){ - callbackWithParam( callbackParam ); - }else if(callback!=null){ - callback(); - }else if(callbackS!=string.Empty){ - if (optional["onCompleteTarget"]!=null){ - customTarget = optional["onCompleteTarget"] as GameObject; - if(callbackParam!=null) customTarget.BroadcastMessage ( callbackS, callbackParam ); - else customTarget.BroadcastMessage( callbackS ); - }else{ - if(callbackParam!=null) trans.gameObject.BroadcastMessage ( callbackS, callbackParam ); - else trans.gameObject.BroadcastMessage( callbackS ); - } - } - - } - #endif - else{ - removeTween(j); - //tween.cleanup(); - } - } - - } -} -#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 -private static void textAlphaRecursive( Transform trans, float val ){ - UnityEngine.UI.Text uiText = trans.gameObject.GetComponent(); - if(uiText!=null){ - Color c = uiText.color; - c.a = val; - uiText.color = c; - } - if(trans.childCount>0){ - foreach (Transform child in trans) { - textAlphaRecursive(child, val); - } - } -} -#endif -private static Color tweenColor( LTDescr tween, float val ){ - Vector3 diff3 = tween.point - tween.axis; - float diffAlpha = tween.to.y - tween.from.y; - return new Color(tween.axis.x + diff3.x*val, tween.axis.y + diff3.y*val, tween.axis.z + diff3.z*val, tween.from.y + diffAlpha*val); -} + public static void removeTween( int i, int uniqueId){ // Only removes the tween if the unique id matches Move a GameObject to a certain location + if(tweens[i].uniqueId==uniqueId){ + removeTween( i ); + } + } -public static void removeTween( int i, int uniqueId){ // Only removes the tween if the unique id matches - if(tweens[i].uniqueId==uniqueId){ - removeTween( i ); - } -} + // This method is only used internally! Do not call this from your scripts. To cancel a tween use LeanTween.cancel + public static void removeTween( int i ){ + if(tweens[i].toggle){ + tweens[i].toggle = false; + tweens[i].counter = uint.MaxValue; + //logError("Removing tween["+i+"]:"+tweens[i]); + if(tweens[i].destroyOnComplete){ +// Debug.Log("destroying tween.type:"+tween.type+" ltRect"+(tweens[i]._optional.ltRect==null)); + if(tweens[i]._optional.ltRect!=null){ + // Debug.Log("destroy i:"+i+" id:"+tweens[i].ltRect.id); + LTGUI.destroy( tweens[i]._optional.ltRect.id ); + }else{ // check if equal to tweenEmpty + if(tweens[i].trans!=null && tweens[i].trans.gameObject!=_tweenEmpty){ + Destroy(tweens[i].trans.gameObject); + } + } + } + //tweens[i].optional = null; + startSearch = i; + //Debug.Log("start search reset:"+startSearch + " i:"+i+" tweenMaxSearch:"+tweenMaxSearch); + if(i+1>=tweenMaxSearch){ + //Debug.Log("reset to zero"); + startSearch = 0; + //tweenMaxSearch--; + } + } + } -// This method is only used internally! Do not call this from your scripts. To cancel a tween use LeanTween.cancel -public static void removeTween( int i ){ - if(tweens[i].toggle){ - tweens[i].toggle = false; - //logError("Removing tween["+i+"]:"+tweens[i]); - if(tweens[i].destroyOnComplete){ - //Debug.Log("destroying tween.type:"+tween.type); - if(tweens[i].ltRect!=null){ - // Debug.Log("destroy i:"+i+" id:"+tweens[i].ltRect.id); - LTGUI.destroy( tweens[i].ltRect.id ); - }else{ // check if equal to tweenEmpty - if(tweens[i].trans.gameObject!=_tweenEmpty){ - Destroy(tweens[i].trans.gameObject); - } - } - } - tweens[i].cleanup(); - //tweens[i].optional = null; - startSearch = i; - //Debug.Log("start search reset:"+startSearch + " i:"+i+" tweenMaxSearch:"+tweenMaxSearch); - if(i+1>=tweenMaxSearch){ - //Debug.Log("reset to zero"); - startSearch = 0; - //tweenMaxSearch--; - } - } -} + public static Vector3[] add(Vector3[] a, Vector3 b){ + Vector3[] c = new Vector3[ a.Length ]; + for(i=0; iCancels all tweens + * + * @method LeanTween.cancelAll + * @param {bool} callComplete:bool (optional) if true, then the all onCompletes will run before canceling + * @example LeanTween.cancelAll(true);
+ */ + public static void cancelAll(){ + cancelAll(false); + } + public static void cancelAll(bool callComplete){ + init(); + for (int i = 0; i <= tweenMaxSearch; i++) + { + if (tweens[i].trans != null){ + if (callComplete && tweens[i].optional.onComplete != null) + tweens[i].optional.onComplete(); + removeTween(i); + } + } + } -/** -* Cancels all tweens -* -* @method LeanTween.cancelAll -* @param {bool} callComplete:bool (optional) if true, then the all onCompletes will run before canceling -* @example LeanTween.cancelAll(true);
-*/ -public static void cancelAll(){ - cancelAll(false); -} -public static void cancelAll(bool callComplete){ - init(); - for (int i = 0; i <= tweenMaxSearch; i++) - { - if (tweens[i].trans != null){ - if (callComplete && tweens[i].onComplete != null) - tweens[i].onComplete(); - removeTween(i); + /** + * Cancel all tweens that are currently targeting the gameObjectCancel all tweens that are currently targeting the gameObject + * + * @method LeanTween.cancel + * @param {GameObject} gameObject:GameObject gameObject whose tweens you wish to cancel + * @param {bool} callOnComplete:bool (optional) whether to call the onComplete method before canceling + * @example LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f);
+ * LeanTween.cancel( gameObject ); + */ + public static void cancel( GameObject gameObject ){ + cancel( gameObject, false); + } + public static void cancel( GameObject gameObject, bool callOnComplete ){ + init(); + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle && tweens[i].trans==trans){ + if (callOnComplete && tweens[i].optional.onComplete != null) + tweens[i].optional.onComplete(); + removeTween(i); + } } } -} -/** -* Cancel all tweens that are currently targeting the gameObject -* -* @method LeanTween.cancel -* @param {GameObject} gameObject:GameObject gameObject whose tweens you wish to cancel -* @param {bool} callOnComplete:bool (optional) whether to call the onComplete method before canceling -* @example LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f);
-* LeanTween.cancel( gameObject ); -*/ -public static void cancel( GameObject gameObject ){ - cancel( gameObject, false); -} -public static void cancel( GameObject gameObject, bool callOnComplete ){ - init(); - Transform trans = gameObject.transform; - for(int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].toggle && tweens[i].trans==trans){ - if (callOnComplete && tweens[i].onComplete != null) - tweens[i].onComplete(); - removeTween(i); - } - } -} + public static void cancel( RectTransform rect ){ + cancel( rect.gameObject, false); + } -public static void cancel( GameObject gameObject, int uniqueId ){ - if(uniqueId>=0){ - init(); - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" counter:"+backCounter + " setCounter:"+ tweens[backId].counter + " tweens[id].type:"+tweens[backId].type); - if(tweens[backId].trans==null || (tweens[backId].trans.gameObject == gameObject && tweens[backId].counter==backCounter)) - removeTween((int)backId); - } -} +// public static void cancel( GameObject gameObject, int uniqueId ){ +// if(uniqueId>=0){ +// init(); +// int backId = uniqueId & 0xFFFF; +// int backCounter = uniqueId >> 16; +// // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" counter:"+backCounter + " setCounter:"+ tweens[backId].counter + " tweens[id].type:"+tweens[backId].type); +// if(tweens[backId].trans==null || (tweens[backId].trans.gameObject == gameObject && tweens[backId].counter==backCounter)) +// removeTween((int)backId); +// } +// } + + public static void cancel( GameObject gameObject, int uniqueId, bool callOnComplete = false ){ + if(uniqueId>=0){ + init(); + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" counter:"+backCounter + " setCounter:"+ tw eens[backId].counter + " tweens[id].type:"+tweens[backId].type); + if(tweens[backId].trans==null || (tweens[backId].trans.gameObject == gameObject && tweens[backId].counter==backCounter)) { + if (callOnComplete && tweens[backId].optional.onComplete != null) + tweens[backId].optional.onComplete(); + removeTween((int)backId); + } + } + } -public static void cancel( LTRect ltRect, int uniqueId ){ - if(uniqueId>=0){ - init(); - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); - if(tweens[backId].ltRect == ltRect && tweens[backId].counter==backCounter) - removeTween((int)backId); - } -} + public static void cancel( LTRect ltRect, int uniqueId ){ + if(uniqueId>=0){ + init(); + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); + if(tweens[backId]._optional.ltRect == ltRect && tweens[backId].counter==backCounter) + removeTween((int)backId); + } + } -/** -* Cancel a specific tween with the provided id -* -* @method LeanTween.cancel -* @param {int} id:int unique id that represents that tween -* @param {bool} callOnComplete:int (optional) whether to call the onComplete method before canceling -* @example int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).id;
-* LeanTween.cancel( id ); -*/ -public static void cancel( int uniqueId ){ - cancel( uniqueId, false); -} -public static void cancel( int uniqueId, bool callOnComplete ){ - if(uniqueId>=0){ - init(); - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); - if(tweens[backId].counter==backCounter){ - if(callOnComplete && tweens[backId].onComplete != null) - tweens[backId].onComplete(); - removeTween((int)backId); - } - } -} + /** + * Cancel a specific tween with the provided id Cancel a specific tween with the provided id + * + * @method LeanTween.cancel + * @param {int} id:int unique id that represents that tween + * @param {bool} callOnComplete:bool (optional) whether to call the onComplete method before canceling + * @example int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).id;
+ * LeanTween.cancel( id ); + */ + public static void cancel( int uniqueId ){ + cancel( uniqueId, false); + } + public static void cancel( int uniqueId, bool callOnComplete ){ + if(uniqueId>=0){ + init(); + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if (backId > tweens.Length - 1) { // sequence + int sequenceId = backId - tweens.Length; + LTSeq seq = sequences[sequenceId]; + for (int i = 0; i < maxSequences; i++) { + if (seq.current.tween != null) { + int tweenId = seq.current.tween.uniqueId; + int tweenIndex = tweenId & 0xFFFF; + removeTween(tweenIndex); + } + if (seq.previous == null) + break; + seq.current = seq.previous; + } + } else { // tween + // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); + if (tweens[backId].counter == backCounter) { + if (callOnComplete && tweens[backId].optional.onComplete != null) + tweens[backId].optional.onComplete(); + removeTween((int)backId); + } + } + } + } -/** -* Retrieve a tweens LTDescr object to modify -* -* @method LeanTween.descr -* @param {int} id:int unique id that represents that tween -* @example int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod ).id;

-*
// later I want decide I want to change onComplete method
-* LTDescr descr = LeanTween.descr( id );
-* if(descr!=null) // if the tween has already finished it will come back null
-*   descr.setOnComplete( newMethod );
-*/ -public static LTDescr descr( int uniqueId ){ - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - - if(tweens[backId]!=null && tweens[backId].uniqueId == uniqueId && tweens[backId].counter==backCounter) - return tweens[backId]; - for(int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].uniqueId == uniqueId && tweens[i].counter==backCounter) - return tweens[i]; - } - return null; -} + /** + * Retrieve a tweens LTDescr object to modify Retrieve a tweens LTDescr object to modify + * + * @method LeanTween.descr + * @param {int} id:int unique id that represents that tween + * @example int id = LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod ).id;

+ *
// later I want decide I want to change onComplete method
+ * LTDescr descr = LeanTween.descr( id );
+ * if(descr!=null) // if the tween has already finished it will come back null
+ *   descr.setOnComplete( newMethod );
+ */ + public static LTDescr descr( int uniqueId ){ + init(); + + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + +// Debug.Log("backId:" + backId+" backCounter:"+backCounter); + if (tweens[backId] != null && tweens[backId].uniqueId == uniqueId && tweens[backId].counter == backCounter) { + // Debug.Log("tween count:" + tweens[backId].counter); + return tweens[backId]; + } + for(int i = 0; i <= tweenMaxSearch; i++){ + if (tweens[i].uniqueId == uniqueId && tweens[i].counter == backCounter) { + return tweens[i]; + } + } + return null; + } -public static LTDescr description( int uniqueId ){ - return descr( uniqueId ); -} + public static LTDescr description( int uniqueId ){ + return descr( uniqueId ); + } -/** -* Retrieve a tweens LTDescr object(s) to modify -* -* @method LeanTween.descriptions -* @param {GameObject} id:GameObject object whose tween descriptions you want to retrieve -* @example LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod );

-*
// later I want decide I want to change onComplete method
-* LTDescr[] descr = LeanTween.descriptions( gameObject );
-* if(descr.Length>0) // make sure there is a valid description for this target
-*   descr[0].setOnComplete( newMethod );// in this case we only ever expect there to be one tween on this object
-*/ -public static LTDescr[] descriptions(GameObject gameObject = null) { + /** + * Retrieve a tweens LTDescr object(s) to modify Retrieve a tweens LTDescr object(s) to modifyn + * + * @method LeanTween.descriptions + * @param {GameObject} id:GameObject object whose tween descriptions you want to retrieve + * @example LeanTween.move( gameObject, new Vector3(0f,1f,2f), 1f).setOnComplete( oldMethod );

+ *
// later I want decide I want to change onComplete method
+ * LTDescr[] descr = LeanTween.descriptions( gameObject );
+ * if(descr.Length>0) // make sure there is a valid description for this target
+ *   descr[0].setOnComplete( newMethod );// in this case we only ever expect there to be one tween on this object
+ */ + public static LTDescr[] descriptions(GameObject gameObject = null) { if (gameObject == null) return null; List descrs = new List(); @@ -2337,2633 +666,2563 @@ public static LTDescr[] descriptions(GameObject gameObject = null) { return descrs.ToArray(); } -[System.Obsolete("Use 'pause( id )' instead")] -public static void pause( GameObject gameObject, int uniqueId ){ - pause( uniqueId ); -} - -/** -* Pause all tweens for a GameObject -* -* @method LeanTween.pause -* @param {int} id:int Id of the tween you want to pause -* @example -* int id = LeanTween.moveX(gameObject, 5, 1.0).id
-* LeanTween.pause( id );
-* // Later....
-* LeanTween.resume( id ); -*/ -public static void pause( int uniqueId ){ - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - if(tweens[backId].counter==backCounter){ - tweens[backId].pause(); - } -} + [System.Obsolete("Use 'pause( id )' instead")] + public static void pause( GameObject gameObject, int uniqueId ){ + pause( uniqueId ); + } -/** -* Pause all tweens for a GameObject -* -* @method LeanTween.pause -* @param {GameObject} gameObject:GameObject GameObject whose tweens you want to pause -*/ -public static void pause( GameObject gameObject ){ - Transform trans = gameObject.transform; - for(int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].trans==trans){ - tweens[i].pause(); - } - } -} + /** + * Pause all tweens for a GameObject Pause all tweens for a GameObject + * + * @method LeanTween.pause + * @param {int} id:int Id of the tween you want to pause + * @example + * int id = LeanTween.moveX(gameObject, 5, 1.0).id
+ * LeanTween.pause( id );
+ * // Later....
+ * LeanTween.resume( id ); + */ + public static void pause( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if(tweens[backId].counter==backCounter){ + tweens[backId].pause(); + } + } -/** -* Pause all active tweens -* -* @method LeanTween.pauseAll -*/ -public static void pauseAll(){ - init(); - for (int i = 0; i <= tweenMaxSearch; i++){ - tweens[i].pause(); + /** + * Pause all tweens for a GameObject Pause all tweens for a GameObject + * + * @method LeanTween.pause + * @param {GameObject} gameObject:GameObject GameObject whose tweens you want to pause + */ + public static void pause( GameObject gameObject ){ + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].trans==trans){ + tweens[i].pause(); + } + } } -} -/** -* Resume all active tweens -* -* @method LeanTween.resumeAll -*/ -public static void resumeAll(){ - init(); - for (int i = 0; i <= tweenMaxSearch; i++){ - tweens[i].resume(); + /** + * Pause all active tweens Pause all active tweens + * + * @method LeanTween.pauseAll + */ + public static void pauseAll(){ + init(); + for (int i = 0; i <= tweenMaxSearch; i++){ + tweens[i].pause(); + } } -} -[System.Obsolete("Use 'resume( id )' instead")] -public static void resume( GameObject gameObject, int uniqueId ){ - resume( uniqueId ); -} + /** + * Resume all active tweens Resume all active tweens + * + * @method LeanTween.resumeAll + */ + public static void resumeAll(){ + init(); + for (int i = 0; i <= tweenMaxSearch; i++){ + tweens[i].resume(); + } + } -/** -* Resume a specific tween -* -* @method LeanTween.resume -* @param {int} id:int Id of the tween you want to resume -* @example -* int id = LeanTween.moveX(gameObject, 5, 1.0).id
-* LeanTween.pause( id );
-* // Later....
-* LeanTween.resume( id ); -*/ -public static void resume( int uniqueId ){ - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - if(tweens[backId].counter==backCounter){ - tweens[backId].resume(); - } -} + [System.Obsolete("Use 'resume( id )' instead")] + public static void resume( GameObject gameObject, int uniqueId ){ + resume( uniqueId ); + } -/** -* Resume all the tweens on a GameObject -* -* @method LeanTween.resume -* @param {GameObject} gameObject:GameObject GameObject whose tweens you want to resume -*/ -public static void resume( GameObject gameObject ){ - Transform trans = gameObject.transform; - for(int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].trans==trans) - tweens[i].resume(); - } -} + /** + * Resume a specific tween Resume a specific tween + * + * @method LeanTween.resume + * @param {int} id:int Id of the tween you want to resume + * @example + * int id = LeanTween.moveX(gameObject, 5, 1.0).id
+ * LeanTween.pause( id );
+ * // Later....
+ * LeanTween.resume( id ); + */ + public static void resume( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if(tweens[backId].counter==backCounter){ + tweens[backId].resume(); + } + } -/** -* Test whether or not a tween is active on a GameObject -* -* @method LeanTween.isTweening -* @param {GameObject} gameObject:GameObject GameObject that you want to test if it is tweening -*/ -public static bool isTweening( GameObject gameObject = null ){ - if(gameObject==null){ - for(int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].toggle) - return true; - } - return false; - } - Transform trans = gameObject.transform; - for(int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].toggle && tweens[i].trans==trans) - return true; - } - return false; -} + /** + * Resume all the tweens on a GameObject Resume all the tweens on a GameObject + * + * @method LeanTween.resume + * @param {GameObject} gameObject:GameObject GameObject whose tweens you want to resume + */ + public static void resume( GameObject gameObject ){ + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].trans==trans) + tweens[i].resume(); + } + } -/** -* Test whether or not a tween is active or not -* -* @method LeanTween.isTweening -* @param {GameObject} id:int id of the tween that you want to test if it is tweening -* @example -* int id = LeanTween.moveX(gameObject, 1f, 3f).id;
-* if(LeanTween.isTweening( id ))
-*      Debug.Log("I am tweening!");
-*/ -public static bool isTweening( int uniqueId ){ - int backId = uniqueId & 0xFFFF; - int backCounter = uniqueId >> 16; - if (backId < 0 || backId >= maxTweens) return false; - // Debug.Log("tweens[backId].counter:"+tweens[backId].counter+" backCounter:"+backCounter +" toggle:"+tweens[backId].toggle); - if(tweens[backId].counter==backCounter && tweens[backId].toggle){ - return true; - } - return false; -} + /** + * Test whether or not a tween is active on a GameObject Test whether or not a tween is active on a GameObject + * + * @method LeanTween.isTweening + * @param {GameObject} gameObject:GameObject GameObject that you want to test if it is tweening + */ + public static bool isTweening( GameObject gameObject = null ){ + if(gameObject==null){ + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle) + return true; + } + return false; + } + Transform trans = gameObject.transform; + for(int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle && tweens[i].trans==trans) + return true; + } + return false; + } -public static bool isTweening( LTRect ltRect ){ - for( int i = 0; i <= tweenMaxSearch; i++){ - if(tweens[i].toggle && tweens[i].ltRect==ltRect) - return true; - } - return false; -} + public static bool isTweening( RectTransform rect ){ + return isTweening(rect.gameObject); + } -public static void drawBezierPath(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float arrowSize = 0.0f, Transform arrowTransform = null){ - Vector3 last = a; - Vector3 p; - Vector3 aa = (-a + 3*(b-c) + d); - Vector3 bb = 3*(a+c) - 6*b; - Vector3 cc = 3*(b-a); - - float t; - - if(arrowSize>0.0f){ - Vector3 beforePos = arrowTransform.position; - Quaternion beforeQ = arrowTransform.rotation; - float distanceTravelled = 0f; - - for(float k = 1.0f; k <= 120.0f; k++){ - t = k / 120.0f; - p = ((aa* t + (bb))* t + cc)* t + a; - Gizmos.DrawLine(last, p); - distanceTravelled += (p-last).magnitude; - if(distanceTravelled>1f){ - distanceTravelled = distanceTravelled - 1f; - /*float deltaY = p.y - last.y; - float deltaX = p.x - last.x; - float ang = Mathf.Atan(deltaY / deltaX); - Vector3 arrow = p + new Vector3( Mathf.Cos(ang+2.5f), Mathf.Sin(ang+2.5f), 0f)*0.5f; - Gizmos.DrawLine(p, arrow); - arrow = p + new Vector3( Mathf.Cos(ang+-2.5f), Mathf.Sin(ang+-2.5f), 0f)*0.5f; - Gizmos.DrawLine(p, arrow);*/ - - arrowTransform.position = p; - arrowTransform.LookAt( last, Vector3.forward ); - Vector3 to = arrowTransform.TransformDirection(Vector3.right); - // Debug.Log("to:"+to+" tweenEmpty.transform.position:"+arrowTransform.position); - Vector3 back = (last-p); - back = back.normalized; - Gizmos.DrawLine(p, p + (to + back)*arrowSize); - to = arrowTransform.TransformDirection(-Vector3.right); - Gizmos.DrawLine(p, p + (to + back)*arrowSize); - } - last = p; - } - - arrowTransform.position = beforePos; - arrowTransform.rotation = beforeQ; - }else{ - for(float k = 1.0f; k <= 30.0f; k++){ - t = k / 30.0f; - p = ((aa* t + (bb))* t + cc)* t + a; - Gizmos.DrawLine(last, p); - last = p; - } - } -} + /** + * Test whether or not a tween is active or not Test whether or not a tween is active or not + * + * @method LeanTween.isTweening + * @param {GameObject} id:int id of the tween that you want to test if it is tweening + * @example + * int id = LeanTween.moveX(gameObject, 1f, 3f).id;
+ * if(LeanTween.isTweening( id ))
+ *      Debug.Log("I am tweening!");
+ */ + public static bool isTweening( int uniqueId ){ + int backId = uniqueId & 0xFFFF; + int backCounter = uniqueId >> 16; + if (backId < 0 || backId >= maxTweens) return false; + // Debug.Log("tweens[backId].counter:"+tweens[backId].counter+" backCounter:"+backCounter +" toggle:"+tweens[backId].toggle); + if(tweens[backId].counter==backCounter && tweens[backId].toggle){ + return true; + } + return false; + } -public static object logError( string error ){ - if(throwErrors) Debug.LogError(error); else Debug.Log(error); - return null; -} + public static bool isTweening( LTRect ltRect ){ + for( int i = 0; i <= tweenMaxSearch; i++){ + if(tweens[i].toggle && tweens[i]._optional.ltRect==ltRect) + return true; + } + return false; + } -// LeanTween 2.0 Methods - -public static LTDescr options(LTDescr seed){ Debug.LogError("error this function is no longer used"); return null; } -public static LTDescr options(){ - init(); - - bool found = false; - for(j=0, i = startSearch; j < maxTweens; i++){ - if(i>=maxTweens-1) - i = 0; - if(tweens[i].toggle==false){ - if(i+1>tweenMaxSearch) - tweenMaxSearch = i+1; - startSearch = i + 1; - found = true; - break; - } - - j++; - if(j >= maxTweens) - return logError("LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( "+(maxTweens*2)+" );") as LTDescr; - } - if(found==false) - logError("no available tween found!"); - - // Debug.Log("new tween with i:"+i+" counter:"+tweens[i].counter+" tweenMaxSearch:"+tweenMaxSearch+" tween:"+tweens[i]); - tweens[i].reset(); - tweens[i].setId( (uint)i ); - - return tweens[i]; -} + public static void drawBezierPath(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float arrowSize = 0.0f, Transform arrowTransform = null){ + Vector3 last = a; + Vector3 p; + Vector3 aa = (-a + 3*(b-c) + d); + Vector3 bb = 3*(a+c) - 6*b; + Vector3 cc = 3*(b-a); + + float t; + + if(arrowSize>0.0f){ + Vector3 beforePos = arrowTransform.position; + Quaternion beforeQ = arrowTransform.rotation; + float distanceTravelled = 0f; + + for(float k = 1.0f; k <= 120.0f; k++){ + t = k / 120.0f; + p = ((aa* t + (bb))* t + cc)* t + a; + Gizmos.DrawLine(last, p); + distanceTravelled += (p-last).magnitude; + if(distanceTravelled>1f){ + distanceTravelled = distanceTravelled - 1f; + /*float deltaY = p.y - last.y; + float deltaX = p.x - last.x; + float ang = Mathf.Atan(deltaY / deltaX); + Vector3 arrow = p + new Vector3( Mathf.Cos(ang+2.5f), Mathf.Sin(ang+2.5f), 0f)*0.5f; + Gizmos.DrawLine(p, arrow); + arrow = p + new Vector3( Mathf.Cos(ang+-2.5f), Mathf.Sin(ang+-2.5f), 0f)*0.5f; + Gizmos.DrawLine(p, arrow);*/ + + arrowTransform.position = p; + arrowTransform.LookAt( last, Vector3.forward ); + Vector3 to = arrowTransform.TransformDirection(Vector3.right); + // Debug.Log("to:"+to+" tweenEmpty.transform.position:"+arrowTransform.position); + Vector3 back = (last-p); + back = back.normalized; + Gizmos.DrawLine(p, p + (to + back)*arrowSize); + to = arrowTransform.TransformDirection(-Vector3.right); + Gizmos.DrawLine(p, p + (to + back)*arrowSize); + } + last = p; + } -public static GameObject tweenEmpty{ - get{ - init(maxTweens); - return _tweenEmpty; - } -} + arrowTransform.position = beforePos; + arrowTransform.rotation = beforeQ; + }else{ + for(float k = 1.0f; k <= 30.0f; k++){ + t = k / 30.0f; + p = ((aa* t + (bb))* t + cc)* t + a; + Gizmos.DrawLine(last, p); + last = p; + } + } + } -public static int startSearch = 0; -public static LTDescr d; - -private static LTDescr pushNewTween( GameObject gameObject, Vector3 to, float time, TweenAction tweenAction, LTDescr tween ){ - init(maxTweens); - if(gameObject==null || tween==null) - return null; - - tween.trans = gameObject.transform; - tween.to = to; - tween.time = time; - tween.type = tweenAction; - //tween.hasPhysics = gameObject.rigidbody!=null; - - return tween; -} + public static object logError( string error ){ + if(throwErrors) Debug.LogError(error); else Debug.Log(error); + return null; + } -#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 -/** -* Play a sequence of images on a Unity UI Object -* -* @method LeanTween.play -* @param {RectTransform} rectTransform:RectTransform RectTransform that you want to play the sequence of sprites on -* @param {Sprite[]} sprites:Sprite[] Sequence of sprites to be played -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* LeanTween.play(gameObject.GetComponent(), sprites).setLoopPingPong(); -*/ -public static LTDescr play(RectTransform rectTransform, UnityEngine.Sprite[] sprites){ - float defaultFrameRate = 0.25f; - float time = defaultFrameRate * sprites.Length; - return pushNewTween(rectTransform.gameObject, new Vector3((float)sprites.Length - 1.0f,0,0), time, TweenAction.CANVAS_PLAYSPRITE, options().setSprites( sprites ).setRepeat(-1)); -} -#endif + public static LTDescr options(LTDescr seed){ Debug.LogError("error this function is no longer used"); return null; } + public static LTDescr options(){ + init(); + + bool found = false; + // Debug.Log("Search start"); + for(j=0, i = startSearch; j <= maxTweens; i++){ + if(j >= maxTweens) + return logError("LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( "+(maxTweens*2)+" );") as LTDescr; + if(i>=maxTweens) + i = 0; + // Debug.Log("searching i:"+i); + if(tweens[i].toggle==false){ + if(i+1>tweenMaxSearch) + tweenMaxSearch = i+1; + startSearch = i + 1; + found = true; + break; + } -/** -* Fade a gameobject's material to a certain alpha value. The material's shader needs to support alpha. Owl labs has some excellent efficient shaders. -* -* @method LeanTween.alpha -* @param {GameObject} gameObject:GameObject Gameobject that you wish to fade -* @param {float} to:float the final alpha value (0-1) -* @param {float} time:float The time with which to fade the object -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* LeanTween.alpha(gameObject, 1f, 1f) .setDelay(1f); -*/ -public static LTDescr alpha(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ALPHA, options() ); -} + j++; + } + if(found==false) + logError("no available tween found!"); -/** -* Fade a GUI Object -* -* @method LeanTween.alpha -* @param {LTRect} ltRect:LTRect LTRect that you wish to fade -* @param {float} to:float the final alpha value (0-1) -* @param {float} time:float The time with which to fade the object -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* LeanTween.alpha(ltRect, 1f, 1f) .setEase(LeanTweenType.easeInCirc); -*/ -public static LTDescr alpha(LTRect ltRect, float to, float time){ - ltRect.alphaEnabled = true; - return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, TweenAction.GUI_ALPHA, options().setRect( ltRect ) ); -} + // Debug.Log("new tween with i:"+i+" counter:"+tweens[i].counter+" tweenMaxSearch:"+tweenMaxSearch+" tween:"+tweens[i]); + tweens[i].reset(); + global_counter++; + if(global_counter>0x8000) + global_counter = 0; + + tweens[i].setId( (uint)i, global_counter ); -#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 -/** -* Fade a Unity UI Object -* -* @method LeanTween.textAlpha -* @param {RectTransform} rectTransform:RectTransform RectTransform that you wish to fade -* @param {float} to:float the final alpha value (0-1) -* @param {float} time:float The time with which to fade the object -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* LeanTween.textAlpha(gameObject.GetComponent<RectTransform>(), 1f, 1f) .setEase(LeanTweenType.easeInCirc); -*/ -public static LTDescr textAlpha(RectTransform rectTransform, float to, float time){ - return pushNewTween(rectTransform.gameObject, new Vector3(to,0,0), time, TweenAction.TEXT_ALPHA, options()); -} -#endif + return tweens[i]; + } -/** -* This works by tweening the vertex colors directly.
-
-Vertex-based coloring is useful because you avoid making a copy of your -object's material for each instance that needs a different color.
-
-A shader that supports vertex colors is required for it to work -(for example the shaders in Mobile/Particles/) -* -* @method LeanTween.alphaVertex -* @param {GameObject} gameObject:GameObject Gameobject that you wish to alpha -* @param {float} to:float The alpha value you wish to tween to -* @param {float} time:float The time with which to delay before calling the function -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr alphaVertex(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0f,0f), time, TweenAction.ALPHA_VERTEX, options() ); -} -/** -* Change a gameobject's material to a certain color value. The material's shader needs to support color tinting. Owl labs has some excellent efficient shaders. -* -* @method LeanTween.color -* @param {GameObject} gameObject:GameObject Gameobject that you wish to change the color -* @param {Color} to:Color the final color value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f) -* @param {float} time:float The time with which to fade the object -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* LeanTween.color(gameObject, Color.yellow, 1f) .setDelay(1f); -*/ -public static LTDescr color(GameObject gameObject, Color to, float time){ - return pushNewTween( gameObject, new Vector3(1.0f, to.a, 0.0f), time, TweenAction.COLOR, options().setPoint( new Vector3(to.r, to.g, to.b) ) ); -} + public static GameObject tweenEmpty{ + get{ + init(maxTweens); + return _tweenEmpty; + } + } -#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 -/** -* Change the color a Unity UI Object -* -* @method LeanTween.textColor -* @param {RectTransform} rectTransform:RectTransform RectTransform that you wish to fade -* @param {Color} to:Color the final alpha value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f) -* @param {float} time:float The time with which to fade the object -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* LeanTween.textColor(gameObject.GetComponent<RectTransform>(), Color.yellow, 1f) .setDelay(1f); -*/ -public static LTDescr textColor(RectTransform rectTransform, Color to, float time){ - return pushNewTween(rectTransform.gameObject, new Vector3(1.0f, to.a, 0.0f), time, TweenAction.TEXT_COLOR, options().setPoint(new Vector3(to.r, to.g, to.b))); -} -#endif + public static int startSearch = 0; + public static LTDescr d; -public static LTDescr delayedCall( float delayTime, Action callback){ - return pushNewTween( tweenEmpty, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete(callback) ); -} + private static LTDescr pushNewTween( GameObject gameObject, Vector3 to, float time, LTDescr tween ){ + init(maxTweens); + if(gameObject==null || tween==null) + return null; -public static LTDescr delayedCall( float delayTime, Action callback){ - return pushNewTween( tweenEmpty, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete(callback) ); -} + tween.trans = gameObject.transform; + tween.to = to; + tween.time = time; -public static LTDescr delayedCall( GameObject gameObject, float delayTime, Action callback){ - return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete(callback) ); -} + if (tween.time <= 0f) + tween.updateInternal(); + //tween.hasPhysics = gameObject.rigidbody!=null; -public static LTDescr delayedCall( GameObject gameObject, float delayTime, Action callback){ - return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete(callback) ); -} + return tween; + } -public static LTDescr destroyAfter( LTRect rect, float delayTime){ - return pushNewTween( tweenEmpty, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setRect( rect ).setDestroyOnComplete(true) ); -} + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Play a sequence of images on a Unity UI Object Play a sequence of images on a Unity UI Object + * + * @method LeanTween.play + * @param {RectTransform} rectTransform:RectTransform RectTransform that you want to play the sequence of sprites on + * @param {Sprite[]} sprites:Sprite[] Sequence of sprites to be played + * @return {LTDescr} LTDescr an object that distinguishes the tween
+ * @example + * LeanTween.play(gameObject.GetComponent<RectTransform>(), sprites).setLoopPingPong(); + */ + public static LTDescr play(RectTransform rectTransform, UnityEngine.Sprite[] sprites){ + float defaultFrameRate = 0.25f; + float time = defaultFrameRate * sprites.Length; + return pushNewTween(rectTransform.gameObject, new Vector3((float)sprites.Length - 1.0f,0,0), time, options().setCanvasPlaySprite().setSprites( sprites ).setRepeat(-1)); + } + #endif -/*public static LTDescr delayedCall(GameObject gameObject, float delayTime, string callback){ - return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete( callback ) ); -}*/ + /** + * Fade a gameobject's material to a certain alpha value. The material's shader needs to support alpha. Owl labs has some excellent efficient shaders. Fade a gameobject's material to a certain alpha value. + * + * @method LeanTween.alpha + * @param {GameObject} gameObject:GameObject Gameobject that you wish to fade + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alpha(gameObject, 1f, 1f) .setDelay(1f); + */ + public static LTDescr alpha(GameObject gameObject, float to, float time){ + LTDescr lt = pushNewTween( gameObject, new Vector3(to,0,0), time, options().setAlpha() ); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + SpriteRenderer ren = gameObject.GetComponent(); + lt.spriteRen = ren; + #endif + return lt; + } -/** -* Move a GameObject to a certain location -* -* @method LeanTween.move -* @param {GameObject} gameObject:GameObject Gameobject that you wish to move -* @param {Vector3} vec:Vector3 to The final positin with which to move to -* @param {float} time:float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.move(gameObject, new Vector3(0f,-3f,5f), 2.0f) .setEase( LeanTweenType.easeOutQuad ); -*/ -public static LTDescr move(GameObject gameObject, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.MOVE, options() ); -} -public static LTDescr move(GameObject gameObject, Vector2 to, float time){ - return pushNewTween( gameObject, new Vector3(to.x, to.y, gameObject.transform.position.z), time, TweenAction.MOVE, options() ); -} + /** + * Retrieve a sequencer object where you can easily chain together tweens and methods one after another Retrieve a sequencer object where you can easily chain together tweens and methods one after another + * + * @method LeanTween.sequence + * @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to + * @example + * var seq = LeanTween.sequence();
+ * seq.add(1f); // delay everything one second
+ * seq.add( () => { // fire an event before start
+ *  Debug.Log("I have started");
+ * });
+ * seq.add( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween
+ * seq.add( () => { // fire event after tween
+ *  Debug.Log("We are done now");
+ * });;
+ */ + public static LTSeq sequence( bool initSequence = true){ + init(maxTweens); + // Loop through and find available sequence + for (int i = 0; i < sequences.Length; i++) { +// Debug.Log("i:" + i + " sequences[i]:" + sequences[i]); + if (sequences[i].tween==null || sequences[i].tween.toggle == false) { + if (sequences[i].toggle == false) { + LTSeq seq = sequences[i]; + if (initSequence) { + seq.init((uint)(i + tweens.Length), global_counter); + + global_counter++; + if (global_counter > 0x8000) + global_counter = 0; + } else { + seq.reset(); + } + + return seq; + } + } + } + return null; + } -/** -* Move a GameObject along a set of bezier curves -* -* @method LeanTween.move -* @param {GameObject} gameObject:GameObject Gameobject that you wish to move -* @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: Point1,Handle2,Handle1,Point2,... -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Javascript:
-* LeanTween.move(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

-* C#:
-* LeanTween.move(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).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);;
-*/ -public static LTDescr move(GameObject gameObject, Vector3[] to, float time){ - d = options(); - if(d.path==null) - d.path = new LTBezierPath( to ); - else - d.path.setPoints( to ); - - return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, TweenAction.MOVE_CURVED, d ); -} -public static LTDescr move(GameObject gameObject, LTBezierPath to, float time) { - d = options(); - d.path = to; + /** + * Fade a GUI Object Fade a GUI Object + * + * @method LeanTween.alpha + * @param {LTRect} ltRect:LTRect LTRect that you wish to fade + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alpha(ltRect, 1f, 1f) .setEase(LeanTweenType.easeInCirc); + */ + public static LTDescr alpha(LTRect ltRect, float to, float time){ + ltRect.alphaEnabled = true; + return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, options().setGUIAlpha().setRect( ltRect ) ); + } - return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, TweenAction.MOVE_CURVED, d); -} -public static LTDescr move(GameObject gameObject, LTSpline to, float time) { - d = options(); - d.spline = to; + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Fade a Unity UI Object Fade a Unity UI Object + * + * @method LeanTween.alphaText + * @param {RectTransform} rectTransform:RectTransform RectTransform associated with the Text Component you wish to fade + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alphaText(gameObject.GetComponent<RectTransform>(), 1f, 1f) .setEase(LeanTweenType.easeInCirc); + */ + public static LTDescr textAlpha(RectTransform rectTransform, float to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(to,0,0), time, options().setTextAlpha()); + } + public static LTDescr alphaText(RectTransform rectTransform, float to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(to,0,0), time, options().setTextAlpha()); + } - return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, TweenAction.MOVE_SPLINE, d); -} + /** + * Fade a Unity UI Canvas Group Fade a Unity UI Canvas Group + * + * @method LeanTween.alphaCanvas + * @param {RectTransform} rectTransform:RectTransform RectTransform that the CanvasGroup is attached to + * @param {float} to:float the final alpha value (0-1) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.alphaCanvas(gameObject.GetComponent<RectTransform>(), 0f, 1f) .setLoopPingPong(); + */ + public static LTDescr alphaCanvas(CanvasGroup canvasGroup, float to, float time){ + return pushNewTween(canvasGroup.gameObject, new Vector3(to,0,0), time, options().setCanvasGroupAlpha()); + } + #endif -/** -* Move a GameObject through a set of points -* -* @method LeanTween.moveSpline -* @param {GameObject} gameObject:GameObject Gameobject that you wish to move -* @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd
Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value. -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Javascript:
-* LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

-* C#:
-* 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).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
-*/ -public static LTDescr moveSpline(GameObject gameObject, Vector3[] to, float time){ - d = options(); - d.spline = new LTSpline( to ); + /** + * This works by tweening the vertex colors directly.
This works by tweening the vertex colors directly +
+ Vertex-based coloring is useful because you avoid making a copy of your + object's material for each instance that needs a different color.
+
+ A shader that supports vertex colors is required for it to work + (for example the shaders in Mobile/Particles/) + * + * @method LeanTween.alphaVertex + * @param {GameObject} gameObject:GameObject Gameobject that you wish to alpha + * @param {float} to:float The alpha value you wish to tween to + * @param {float} time:float The time with which to delay before calling the function + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr alphaVertex(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0f,0f), time, options().setAlphaVertex() ); + } - return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, TweenAction.MOVE_SPLINE, d ); -} + /** + * Change a gameobject's material to a certain color value. The material's shader needs to support color tinting. Owl labs has some excellent efficient shaders. Change a gameobject's material to a certain color value + * + * @method LeanTween.color + * @param {GameObject} gameObject:GameObject Gameobject that you wish to change the color + * @param {Color} to:Color the final color value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.color(gameObject, Color.yellow, 1f) .setDelay(1f); + */ + public static LTDescr color(GameObject gameObject, Color to, float time){ + LTDescr lt = pushNewTween( gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setColor().setPoint( new Vector3(to.r, to.g, to.b) ) ); + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + SpriteRenderer ren = gameObject.GetComponent(); + lt.spriteRen = ren; + #endif + return lt; + } -/** -* Move a GameObject through a set of points, in local space -* -* @method LeanTween.moveSplineLocal -* @param {GameObject} gameObject:GameObject Gameobject that you wish to move -* @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Javascript:
-* LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

-* C#:
-* 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).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
-*/ -public static LTDescr moveSplineLocal(GameObject gameObject, Vector3[] to, float time){ - d = options(); - d.spline = new LTSpline( to ); + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Change the color a Unity UI Object Change the color a Unity UI Object + * + * @method LeanTween.colorText + * @param {RectTransform} rectTransform:RectTransform RectTransform attached to the Text Component whose color you want to change + * @param {Color} to:Color the final alpha value ex: Color.Red, new Color(1.0f,1.0f,0.0f,0.8f) + * @param {float} time:float The time with which to fade the object + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * LeanTween.colorText(gameObject.GetComponent<RectTransform>(), Color.yellow, 1f) .setDelay(1f); + */ + public static LTDescr textColor(RectTransform rectTransform, Color to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setTextColor().setPoint(new Vector3(to.r, to.g, to.b))); + } + public static LTDescr colorText(RectTransform rectTransform, Color to, float time){ + return pushNewTween(rectTransform.gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setTextColor().setPoint(new Vector3(to.r, to.g, to.b))); + } + #endif - return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, TweenAction.MOVE_SPLINE_LOCAL, d ); -} + /** + * Call a method after a specified amount of time Call a method after a specified amount of time + * + * @method LeanTween.delayedCall + * @param {GameObject} gameObject:GameObject Gameobject that you wish to associate with this delayed call + * @param {float} time:float delay The time you wish to pass before the method is called + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.delayedCall(gameObject, 1f, ()=>{
Debug.Log("I am called one second later!");
})); + */ + public static LTDescr delayedCall( float delayTime, Action callback){ + return pushNewTween( tweenEmpty, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } -/** -* Move a GUI Element to a certain location -* -* @method LeanTween.move (GUI) -* @param {LTRect} ltRect:LTRect ltRect LTRect object that you wish to move -* @param {Vector2} vec:Vector2 to The final position with which to move to (pixel coordinates) -* @param {float} time:float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr move(LTRect ltRect, Vector2 to, float time){ - return pushNewTween( tweenEmpty, to, time, TweenAction.GUI_MOVE, options().setRect( ltRect ) ); -} + public static LTDescr delayedCall( float delayTime, Action callback){ + return pushNewTween( tweenEmpty, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } -public static LTDescr moveMargin(LTRect ltRect, Vector2 to, float time){ - return pushNewTween( tweenEmpty, to, time, TweenAction.GUI_MOVE_MARGIN, options().setRect( ltRect ) ); -} + public static LTDescr delayedCall( GameObject gameObject, float delayTime, Action callback){ + return pushNewTween( gameObject, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } -/** -* Move a GameObject along the x-axis -* -* @method LeanTween.moveX -* @param {GameObject} gameObject:GameObject gameObject Gameobject that you wish to move -* @param {float} to:float to The final position with which to move to -* @param {float} time:float time The time to complete the move in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr moveX(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_X, options() ); -} + public static LTDescr delayedCall( GameObject gameObject, float delayTime, Action callback){ + return pushNewTween( gameObject, Vector3.zero, delayTime, options().setCallback().setOnComplete(callback) ); + } -/** -* Move a GameObject along the y-axis -* -* @method LeanTween.moveY -* @param {GameObject} GameObject gameObject Gameobject that you wish to move -* @param {float} float to The final position with which to move to -* @param {float} float time The time to complete the move in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr moveY(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_Y, options() ); -} + public static LTDescr destroyAfter( LTRect rect, float delayTime){ + return pushNewTween( tweenEmpty, Vector3.zero, delayTime, options().setCallback().setRect( rect ).setDestroyOnComplete(true) ); + } -/** -* Move a GameObject along the z-axis -* -* @method LeanTween.moveZ -* @param {GameObject} GameObject gameObject Gameobject that you wish to move -* @param {float} float to The final position with which to move to -* @param {float} float time The time to complete the move in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr moveZ(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_Z, options() ); -} + /*public static LTDescr delayedCall(GameObject gameObject, float delayTime, string callback){ + return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setOnComplete( callback ) ); + }*/ -/** -* Move a GameObject to a certain location relative to the parent transform. -* -* @method LeanTween.moveLocal -* @param {GameObject} GameObject gameObject Gameobject that you wish to rotate -* @param {Vector3} Vector3 to The final positin with which to move to -* @param {float} float time The time to complete the tween in -* @param {Hashtable} Hashtable optional Hashtable where you can pass optional items. -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr moveLocal(GameObject gameObject, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.MOVE_LOCAL, options() ); -} -/** -* Move a GameObject along a set of bezier curves, in local space -* -* @method LeanTween.moveLocal -* @param {GameObject} gameObject:GameObject Gameobject that you wish to move -* @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: Point1,Handle1,Handle2,Point2,... -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Javascript:
-* LeanTween.move(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

-* C#:
-* LeanTween.move(gameObject, new Vector3[]{Vector3(0f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,1f)}).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
-*/ -public static LTDescr moveLocal(GameObject gameObject, Vector3[] to, float time){ - d = options(); - if(d.path==null) - d.path = new LTBezierPath( to ); - else - d.path.setPoints( to ); - - return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, TweenAction.MOVE_CURVED_LOCAL, d ); -} + /** + * Move a GameObject to a certain location Move a GameObject to a certain location + * + * @method LeanTween.move + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3} vec:Vector3 to The final positin with which to move to + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.move(gameObject, new Vector3(0f,-3f,5f), 2.0f) .setEase( LeanTweenType.easeOutQuad ); + */ + public static LTDescr move(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setMove() ); + } + public static LTDescr move(GameObject gameObject, Vector2 to, float time){ + return pushNewTween( gameObject, new Vector3(to.x, to.y, gameObject.transform.position.z), time, options().setMove() ); + } -public static LTDescr moveLocalX(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_LOCAL_X, options() ); -} -public static LTDescr moveLocalY(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_LOCAL_Y, options() ); -} + /** + * Move a GameObject along a set of bezier curves Move a GameObject along a set of bezier curves + * + * @method LeanTween.move + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: Point1,Handle2,Handle1,Point2,... + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
+ * LeanTween.move(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

+ * C#:
+ * LeanTween.move(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).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);;
+ */ + public static LTDescr move(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveCurved(); + if(d.optional.path==null) + d.optional.path = new LTBezierPath( to ); + else + d.optional.path.setPoints( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } -public static LTDescr moveLocalZ(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_LOCAL_Z, options() ); -} + public static LTDescr move(GameObject gameObject, LTBezierPath to, float time) { + d = options().setMoveCurved(); + d.optional.path = to; -public static LTDescr moveLocal(GameObject gameObject, LTBezierPath to, float time) { - d = options(); - d.path = to; + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } - return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, TweenAction.MOVE_CURVED_LOCAL, d); -} -public static LTDescr moveLocal(GameObject gameObject, LTSpline to, float time) { - d = options(); - d.spline = to; - - return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, TweenAction.MOVE_SPLINE_LOCAL, d); -} + public static LTDescr move(GameObject gameObject, LTSpline to, float time) { + d = options().setMoveSpline(); + d.optional.spline = to; -/** -* Rotate a GameObject, to values are in passed in degrees -* -* @method LeanTween.rotate -* @param {GameObject} GameObject gameObject Gameobject that you wish to rotate -* @param {Vector3} Vector3 to The final rotation with which to rotate to -* @param {float} float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.rotate(cube, new Vector3(180f,30f,0f), 1.5f); -*/ + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } -public static LTDescr rotate(GameObject gameObject, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.ROTATE, options() ); -} + /** + * Move a GameObject through a set of points Move a GameObject through a set of points + * + * @method LeanTween.moveSpline + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd
Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value. + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
+ * LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

+ * C#:
+ * 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).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
+ */ + public static LTDescr moveSpline(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveSpline(); + d.optional.spline = new LTSpline( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } -/** -* Rotate a GUI element (using an LTRect object), to a value that is in degrees -* -* @method LeanTween.rotate -* @param {LTRect} ltRect:LTRect LTRect that you wish to rotate -* @param {float} to:float The final rotation with which to rotate to -* @param {float} time:float The time to complete the tween in -* @param {Array} optional:Array Object Array where you can pass optional items. -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* if(GUI.Button(buttonRect.rect, "Rotate"))
-* LeanTween.rotate( buttonRect4, 150.0f, 1.0f).setEase(LeanTweenType.easeOutElastic);
-* GUI.matrix = Matrix4x4.identity;
-*/ -public static LTDescr rotate(LTRect ltRect, float to, float time){ - return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, TweenAction.GUI_ROTATE, options().setRect( ltRect ) ); -} + /** + * Move a GameObject through a set of points Move a GameObject through a set of points + * + * @method LeanTween.moveSpline + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {LTSpline} spline:LTSpline pass a pre-existing LTSpline for the object to move along + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
+ * LeanTween.moveSpline(gameObject, ltSpline, 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

+ * C#:
+ * LeanTween.moveSpline(gameObject, ltSpline, 1.5f).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
+ */ + public static LTDescr moveSpline(GameObject gameObject, LTSpline to, float time){ + d = options().setMoveSpline(); + d.optional.spline = to; + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } -/** -* Rotate a GameObject in the objects local space (on the transforms localEulerAngles object) -* -* @method LeanTween.rotateLocal -* @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate -* @param {Vector3} to:Vector3 The final rotation with which to rotate to -* @param {float} time:float The time to complete the rotation in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr rotateLocal(GameObject gameObject, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.ROTATE_LOCAL, options() ); -} + /** + * Move a GameObject through a set of points, in local space Move a GameObject through a set of points, in local space + * + * @method LeanTween.moveSplineLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
+ * LeanTween.moveSpline(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0) .setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

+ * C#:
+ * 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).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
+ */ + public static LTDescr moveSplineLocal(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveSplineLocal(); + d.optional.spline = new LTSpline( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } -/** -* Rotate a GameObject only on the X axis -* -* @method LeanTween.rotateX -* @param {GameObject} GameObject Gameobject that you wish to rotate -* @param {float} to:float The final x-axis rotation with which to rotate -* @param {float} time:float The time to complete the rotation in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr rotateX(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ROTATE_X, options() ); -} + /** + * Move a GUI Element to a certain location Move a GUI Element to a certain location + * + * @method LeanTween.move (GUI) + * @param {LTRect} ltRect:LTRect ltRect LTRect object that you wish to move + * @param {Vector2} vec:Vector2 to The final position with which to move to (pixel coordinates) + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr move(LTRect ltRect, Vector2 to, float time){ + return pushNewTween( tweenEmpty, to, time, options().setGUIMove().setRect( ltRect ) ); + } -/** -* Rotate a GameObject only on the Y axis -* -* @method LeanTween.rotateY -* @param {GameObject} GameObject Gameobject that you wish to rotate -* @param {float} to:float The final y-axis rotation with which to rotate -* @param {float} time:float The time to complete the rotation in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr rotateY(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ROTATE_Y, options() ); -} + public static LTDescr moveMargin(LTRect ltRect, Vector2 to, float time){ + return pushNewTween( tweenEmpty, to, time, options().setGUIMoveMargin().setRect( ltRect ) ); + } -/** -* Rotate a GameObject only on the Z axis -* -* @method LeanTween.rotateZ -* @param {GameObject} GameObject Gameobject that you wish to rotate -* @param {float} to:float The final z-axis rotation with which to rotate -* @param {float} time:float The time to complete the rotation in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr rotateZ(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ROTATE_Z, options() ); -} + /** + * Move a GameObject along the x-axis Move a GameObject along the x-axis + * + * @method LeanTween.moveX + * @param {GameObject} gameObject:GameObject gameObject Gameobject that you wish to move + * @param {float} to:float to The final position with which to move to + * @param {float} time:float time The time to complete the move in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveX() ); + } -/** -* Rotate a GameObject around a certain Axis (the best method to use when you want to rotate beyond 180 degrees) -* -* @method LeanTween.rotateAround -* @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate -* @param {Vector3} vec:Vector3 axis in which to rotate around ex: Vector3.up -* @param {float} degrees:float the degrees in which to rotate -* @param {float} time:float time The time to complete the rotation in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example:
-* LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f ); -*/ -public static LTDescr rotateAround(GameObject gameObject, Vector3 axis, float add, float time){ - return pushNewTween( gameObject, new Vector3(add,0f,0f), time, TweenAction.ROTATE_AROUND, options().setAxis(axis) ); -} + /** + * Move a GameObject along the y-axis Move a GameObject along the y-axis + * + * @method LeanTween.moveY + * @param {GameObject} GameObject gameObject Gameobject that you wish to move + * @param {float} float to The final position with which to move to + * @param {float} float time The time to complete the move in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveY() ); + } -/** -* Rotate a GameObject around a certain Axis in Local Space (the best method to use when you want to rotate beyond 180 degrees) -* -* @method LeanTween.rotateAroundLocal -* @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate -* @param {Vector3} vec:Vector3 axis in which to rotate around ex: Vector3.up -* @param {float} degrees:float the degrees in which to rotate -* @param {float} time:float time The time to complete the rotation in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example:
-* LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f ); -*/ -public static LTDescr rotateAroundLocal(GameObject gameObject, Vector3 axis, float add, float time){ - return pushNewTween( gameObject, new Vector3(add,0f,0f), time, TweenAction.ROTATE_AROUND_LOCAL, options().setAxis(axis) ); -} + /** + * Move a GameObject along the z-axis Move a GameObject along the z-axis + * + * @method LeanTween.moveZ + * @param {GameObject} GameObject gameObject Gameobject that you wish to move + * @param {float} float to The final position with which to move to + * @param {float} float time The time to complete the move in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveZ() ); + } -/** -* Scale a GameObject to a certain size -* -* @method LeanTween.scale -* @param {GameObject} gameObject:GameObject gameObject Gameobject that you wish to scale -* @param {Vector3} vec:Vector3 to The size with which to tween to -* @param {float} time:float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr scale(GameObject gameObject, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.SCALE, options() ); -} - -/** -* Scale a GUI Element to a certain width and height -* -* @method LeanTween.scale (GUI) -* @param {LTRect} LTRect ltRect LTRect object that you wish to move -* @param {Vector2} Vector2 to The final width and height to scale to (pixel based) -* @param {float} float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
-* LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 ).setEase(LeanTweenType.easeOutBounce);
-* function OnGUI(){
-*   if(GUI.Button(bRect.rect, "Scale")){ }
-* }
-*
-* Example C#:
-* LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
-* LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f ).setEase(LeanTweenType.easeOutBounce);
-* void OnGUI(){
-*   if(GUI.Button(bRect.rect, "Scale")){ }
-* }
-*/ -public static LTDescr scale(LTRect ltRect, Vector2 to, float time){ - return pushNewTween( tweenEmpty, to, time, TweenAction.GUI_SCALE, options().setRect( ltRect ) ); -} + /** + * Move a GameObject to a certain location relative to the parent transform. Move a GameObject to a certain location relative to the parent transform. + * + * @method LeanTween.moveLocal + * @param {GameObject} GameObject gameObject Gameobject that you wish to rotate + * @param {Vector3} Vector3 to The final positin with which to move to + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr moveLocal(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setMoveLocal() ); + } -/** -* Scale a GameObject to a certain size along the x-axis only -* -* @method LeanTween.scaleX -* @param {GameObject} gameObject:GameObject Gameobject that you wish to scale -* @param {float} scaleTo:float the size with which to scale to -* @param {float} time:float the time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr scaleX(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.SCALE_X, options() ); -} + /** + * Move a GameObject along a set of bezier curves, in local space Move a GameObject along a set of bezier curves, in local space + * + * @method LeanTween.moveLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Vector3[]} path:Vector3[] A set of points that define the curve(s) ex: Point1,Handle1,Handle2,Point2,... + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Javascript:
+ * LeanTween.moveLocal(gameObject, [Vector3(0,0,0),Vector3(1,0,0),Vector3(1,0,0),Vector3(1,0,1)], 2.0).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);

+ * C#:
+ * LeanTween.moveLocal(gameObject, new Vector3[]{Vector3(0f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,0f),Vector3(1f,0f,1f)}).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);
+ */ + public static LTDescr moveLocal(GameObject gameObject, Vector3[] to, float time){ + d = options().setMoveCurvedLocal(); + if(d.optional.path==null) + d.optional.path = new LTBezierPath( to ); + else + d.optional.path.setPoints( to ); + + return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, d ); + } -/** -* Scale a GameObject to a certain size along the y-axis only -* -* @method LeanTween.scaleY -* @param {GameObject} gameObject:GameObject Gameobject that you wish to scale -* @param {float} scaleTo:float the size with which to scale to -* @param {float} time:float the time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr scaleY(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.SCALE_Y, options() ); -} + public static LTDescr moveLocalX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveLocalX() ); + } -/** -* Scale a GameObject to a certain size along the z-axis only -* -* @method LeanTween.scaleZ -* @param {GameObject} gameObject:GameObject Gameobject that you wish to scale -* @param {float} scaleTo:float the size with which to scale to -* @param {float} time:float the time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr scaleZ(GameObject gameObject, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.SCALE_Z, options()); -} + public static LTDescr moveLocalY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveLocalY() ); + } -/** -* Tween any particular value (float) -* -* @method LeanTween.value (float) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {float} from:float The original value to start the tween from -* @param {Vector3} to:float The final float with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( function( val:float ){
-*  Debug.Log("tweened val:"+val);
-* } );
-*
-* Example C#:
-* LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( (float val)=>{
-*  Debug.Log("tweened val:"+val);
-* } );
-*/ -public static LTDescr value(GameObject gameObject, float from, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.CALLBACK, options().setFrom( new Vector3(from,0,0) ) ); -} + public static LTDescr moveLocalZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setMoveLocalZ() ); + } -/** -* Tween any particular value (Vector2) -* -* @method LeanTween.value (Vector2) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {Vector2} from:Vector2 The original value to start the tween from -* @param {Vector3} to:Vector2 The final Vector2 with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, new Vector2(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( function( val:Vector2 ){
-*  Debug.Log("tweened val:"+val);
-* } );
-*
-* Example C#:
-* LeanTween.value( gameObject, new Vector3(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( (Vector2 val)=>{
-*  Debug.Log("tweened val:"+val);
-* } );
-*/ -public static LTDescr value(GameObject gameObject, Vector2 from, Vector2 to, float time){ - return pushNewTween( gameObject, new Vector3(to.x,to.y,0), time, TweenAction.VALUE3, options().setTo( new Vector3(to.x,to.y,0f) ).setFrom( new Vector3(from.x,from.y,0) ) ); -} + public static LTDescr moveLocal(GameObject gameObject, LTBezierPath to, float time) { + d = options().setMoveCurvedLocal(); + d.optional.path = to; -/** -* Tween any particular value (Vector3) -* -* @method LeanTween.value (Vector3) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {Vector3} from:Vector3 The original value to start the tween from -* @param {Vector3} to:Vector3 The final Vector3 with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( function( val:Vector3 ){
-*  Debug.Log("tweened val:"+val);
-* } );
-*
-* Example C#:
-* LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( (Vector3 val)=>{
-*  Debug.Log("tweened val:"+val);
-* } );
-*/ -public static LTDescr value(GameObject gameObject, Vector3 from, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.VALUE3, options().setFrom( from ) ); -} + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } + public static LTDescr moveLocal(GameObject gameObject, LTSpline to, float time) { + d = options().setMoveSplineLocal(); + d.optional.spline = to; -/** -* Tween any particular value (Color) -* -* @method LeanTween.value (Color) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {Color} from:Color The original value to start the tween from -* @param {Color} to:Color The final Color with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( function( val:Color ){
-*  Debug.Log("tweened val:"+val);
-* } );
-*
-* Example C#:
-* LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( (Color val)=>{
-*  Debug.Log("tweened val:"+val);
-* } );
-*/ -public static LTDescr value(GameObject gameObject, Color from, Color to, float time){ - return pushNewTween( gameObject, new Vector3(1f, to.a, 0f), time, TweenAction.CALLBACK_COLOR, options().setPoint( new Vector3(to.r, to.g, to.b) ) - .setFromColor(from).setHasInitialized(false) - ); -} + return pushNewTween(gameObject, new Vector3(1.0f, 0.0f, 0.0f), time, d); + } -/** -* Tween any particular value, it does not need to be tied to any particular type or GameObject -* -* @method LeanTween.value (float) -* @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject -* @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( float val ){ } -* @param {float} float from The original value to start the tween from -* @param {float} float to The value to end the tween on -* @param {float} float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
-* function updateValueExampleCallback( val:float ){
-*   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
-* }
-*
-* Example C#:
-* LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
-* void updateValueExampleCallback( float val ){
-*   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
-* }
-*/ + /** + * Move a GameObject to another transform Move a GameObject to another transform + * + * @method LeanTween.move + * @param {GameObject} gameObject:GameObject Gameobject that you wish to move + * @param {Transform} destination:Transform Transform whose position the tween will finally end on + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.move(gameObject, anotherTransform, 2.0f) .setEase( LeanTweenType.easeOutQuad ); + */ + public static LTDescr move(GameObject gameObject, Transform to, float time){ + return pushNewTween(gameObject, Vector3.zero, time, options().setTo(to).setMoveToTransform() ); + } -public static LTDescr value(GameObject gameObject, Action callOnUpdate, float from, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.CALLBACK, options().setTo( new Vector3(to,0,0) ).setFrom( new Vector3(from,0,0) ).setOnUpdate(callOnUpdate) ); -} + /** + * Rotate a GameObject, to values are in passed in degrees Rotate a GameObject, to values are in passed in degrees + * + * @method LeanTween.rotate + * @param {GameObject} GameObject gameObject Gameobject that you wish to rotate + * @param {Vector3} Vector3 to The final rotation with which to rotate to + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotate(cube, new Vector3(180f,30f,0f), 1.5f); + */ + + public static LTDescr rotate(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setRotate() ); + } -/** -* Tweens any float value, it does not need to be tied to any particular type or GameObject -* -* @method LeanTween.value (float) -* @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject -* @param {Action} callOnUpdateRatio:Action Function that's called every Update frame. It must accept two float values ex: function updateValue( float val, float ratio){ } -* @param {float} float from The original value to start the tween from -* @param {float} float to The value to end the tween on -* @param {float} float time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
-* function updateValueExampleCallback( val:float, ratio:float ){
-*   Debug.Log("tweened value:"+val+" percent complete:"+ratio*100);
-* }
-*
-* Example C#:
-* LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
-* void updateValueExampleCallback( float val, float ratio ){
-*   Debug.Log("tweened value:"+val+" percent complete:"+ratio*100);
-* }
-*/ + /** + * Rotate a GUI element (using an LTRect object), to a value that is in degrees Rotate a GUI element (using an LTRect object), to a value that is in degrees + * + * @method LeanTween.rotate + * @param {LTRect} ltRect:LTRect LTRect that you wish to rotate + * @param {float} to:float The final rotation with which to rotate to + * @param {float} time:float The time to complete the tween in + * @param {Array} optional:Array Object Array where you can pass optional items. + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * if(GUI.Button(buttonRect.rect, "Rotate"))
+ * LeanTween.rotate( buttonRect4, 150.0f, 1.0f).setEase(LeanTweenType.easeOutElastic);
+ * GUI.matrix = Matrix4x4.identity;
+ */ + public static LTDescr rotate(LTRect ltRect, float to, float time){ + return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, options().setGUIRotate().setRect( ltRect ) ); + } -public static LTDescr value(GameObject gameObject, Action callOnUpdateRatio, float from, float to, float time) { - return pushNewTween(gameObject, new Vector3(to, 0, 0), time, TweenAction.CALLBACK, options().setTo(new Vector3(to, 0, 0)).setFrom(new Vector3(from, 0, 0)).setOnUpdateRatio(callOnUpdateRatio)); -} + /** + * Rotate a GameObject in the objects local space (on the transforms localEulerAngles object) Rotate a GameObject in the objects local space (on the transforms localEulerAngles object) + * + * @method LeanTween.rotateLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate + * @param {Vector3} to:Vector3 The final rotation with which to rotate to + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateLocal(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setRotateLocal() ); + } -/** -* Tween from one color to another -* -* @method LeanTween.value (Color) -* @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject -* @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a color value ex: function updateValue( Color val ){ } -* @param {Color} Color from The original value to start the tween from -* @param {Color} Color to The value to end the tween on -* @param {Color} Color time The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example -* Example Javascript:
-* LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
-* function updateValueExampleCallback( val:Color ){
-*   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
-* }
-*
-* Example C#:
-* LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
-* void updateValueExampleCallback( Color val ){
-*   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
-* }
-*/ + /** + * Rotate a GameObject only on the X axis Rotate a GameObject only on the X axis + * + * @method LeanTween.rotateX + * @param {GameObject} GameObject Gameobject that you wish to rotate + * @param {float} to:float The final x-axis rotation with which to rotate + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setRotateX() ); + } -public static LTDescr value(GameObject gameObject, Action callOnUpdate, Color from, Color to, float time){ - return pushNewTween( gameObject, new Vector3(1.0f,to.a,0.0f), time, TweenAction.CALLBACK_COLOR, options().setPoint( new Vector3(to.r, to.g, to.b) ) - .setAxis( new Vector3(from.r, from.g, from.b) ).setFrom( new Vector3(0.0f, from.a, 0.0f) ).setHasInitialized(false).setOnUpdateColor(callOnUpdate) ); -} + /** + * Rotate a GameObject only on the Y axis Rotate a GameObject only on the Y axis + * + * @method LeanTween.rotateY + * @param {GameObject} GameObject Gameobject that you wish to rotate + * @param {float} to:float The final y-axis rotation with which to rotate + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setRotateY() ); + } -/** -* Tween any particular value (Vector2), this could be used to tween an arbitrary value like offset property -* -* @method LeanTween.value (Vector2) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ } -* @param {float} from:Vector2 The original value to start the tween from -* @param {Vector2} to:Vector2 The final Vector3 with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr value(GameObject gameObject, Action callOnUpdate, Vector2 from, Vector2 to, float time){ - return pushNewTween( gameObject, new Vector3(to.x,to.y,0f), time, TweenAction.VALUE3, options().setTo( new Vector3(to.x,to.y,0f) ).setFrom( new Vector3(from.x,from.y,0f) ).setOnUpdateVector2(callOnUpdate) ); -} + /** + * Rotate a GameObject only on the Z axis Rotate a GameObject only on the Z axis + * + * @method LeanTween.rotateZ + * @param {GameObject} GameObject Gameobject that you wish to rotate + * @param {float} to:float The final z-axis rotation with which to rotate + * @param {float} time:float The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr rotateZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setRotateZ() ); + } -/** -* Tween any particular value (Vector3), this could be used to tween an arbitrary property that uses a Vector -* -* @method LeanTween.value (Vector3) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ } -* @param {float} from:Vector3 The original value to start the tween from -* @param {Vector3} to:Vector3 The final Vector3 with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr value(GameObject gameObject, Action callOnUpdate, Vector3 from, Vector3 to, float time){ - return pushNewTween( gameObject, to, time, TweenAction.VALUE3, options().setTo( to ).setFrom( from ).setOnUpdateVector3(callOnUpdate) ); -} + /** + * Rotate a GameObject around a certain Axis (the best method to use when you want to rotate beyond 180 degrees) Rotate a GameObject around a certain Axis (the best method to use when you want to rotate beyond 180 degrees) + * + * @method LeanTween.rotateAround + * @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate + * @param {Vector3} vec:Vector3 axis in which to rotate around ex: Vector3.up + * @param {float} degrees:float the degrees in which to rotate + * @param {float} time:float time The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example:
+ * LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f ); + */ + public static LTDescr rotateAround(GameObject gameObject, Vector3 axis, float add, float time){ + return pushNewTween( gameObject, new Vector3(add,0f,0f), time, options().setAxis(axis).setRotateAround() ); + } -/** -* Tween any particular value (float) -* -* @method LeanTween.value (float,object) -* @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to -* @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val, object obj ){ } -* @param {float} from:float The original value to start the tween from -* @param {Vector3} to:float The final Vector3 with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -*/ -public static LTDescr value(GameObject gameObject, Action callOnUpdate, float from, float to, float time){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.CALLBACK, options().setTo( new Vector3(to,0,0) ).setFrom( new Vector3(from,0,0) ).setOnUpdateObject(callOnUpdate) ); -} + /** + * Rotate a GameObject around a certain Axis in Local Space (the best method to use when you want to rotate beyond 180 degrees) Rotate a GameObject around a certain Axis in Local Space (the best method to use when you want to rotate beyond 180 degrees) + * + * @method LeanTween.rotateAroundLocal + * @param {GameObject} gameObject:GameObject Gameobject that you wish to rotate + * @param {Vector3} vec:Vector3 axis in which to rotate around ex: Vector3.up + * @param {float} degrees:float the degrees in which to rotate + * @param {float} time:float time The time to complete the rotation in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example:
+ * LeanTween.rotateAround ( gameObject, Vector3.left, 90f, 1f ); + */ + public static LTDescr rotateAroundLocal(GameObject gameObject, Vector3 axis, float add, float time){ + return pushNewTween( gameObject, new Vector3(add,0f,0f), time, options().setRotateAroundLocal().setAxis(axis) ); + } -public static LTDescr delayedSound( AudioClip audio, Vector3 pos, float volume ){ - //Debug.LogError("Delay sound??"); - return pushNewTween( tweenEmpty, pos, 0f, TweenAction.DELAYED_SOUND, options().setTo( pos ).setFrom( new Vector3(volume,0,0) ).setAudio( audio ) ); -} + /** + * Scale a GameObject to a certain size Scale a GameObject to a certain size + * + * @method LeanTween.scale + * @param {GameObject} gameObject:GameObject gameObject Gameobject that you wish to scale + * @param {Vector3} vec:Vector3 to The size with which to tween to + * @param {float} time:float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scale(GameObject gameObject, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setScale() ); + } -public static LTDescr delayedSound( GameObject gameObject, AudioClip audio, Vector3 pos, float volume ){ - //Debug.LogError("Delay sound??"); - return pushNewTween( gameObject, pos, 0f, TweenAction.DELAYED_SOUND, options().setTo( pos ).setFrom( new Vector3(volume,0,0) ).setAudio( audio ) ); -} + /** + * Scale a GUI Element to a certain width and height Scale a GUI Element to a certain width and height + * + * @method LeanTween.scale (GUI) + * @param {LTRect} LTRect ltRect LTRect object that you wish to move + * @param {Vector2} Vector2 to The final width and height to scale to (pixel based) + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
+ * LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 ).setEase(LeanTweenType.easeOutBounce);
+ * function OnGUI(){
+ *   if(GUI.Button(bRect.rect, "Scale")){ }
+ * }
+ *
+ * Example C#:
+ * LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
+ * LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f ).setEase(LeanTweenType.easeOutBounce);
+ * void OnGUI(){
+ *   if(GUI.Button(bRect.rect, "Scale")){ }
+ * }
+ */ + public static LTDescr scale(LTRect ltRect, Vector2 to, float time){ + return pushNewTween( tweenEmpty, to, time, options().setGUIScale().setRect( ltRect ) ); + } -#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 + /** + * Scale a GameObject to a certain size along the x-axis only Scale a GameObject to a certain size along the x-axis only + * + * @method LeanTween.scaleX + * @param {GameObject} gameObject:GameObject Gameobject that you wish to scale + * @param {float} scaleTo:float the size with which to scale to + * @param {float} time:float the time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scaleX(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setScaleX() ); + } -/** -* Move a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.move (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {Vector3} to:Vector3 The final Vector3 with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.move(gameObject.GetComponent<RectTransform>(), new Vector3(200f,-100f,0f), 1f).setDelay(1f); -*/ -public static LTDescr move(RectTransform rectTrans, Vector3 to, float time){ - return pushNewTween( rectTrans.gameObject, to, time, TweenAction.CANVAS_MOVE, options().setRect( rectTrans ) ); -} + /** + * Scale a GameObject to a certain size along the y-axis only Scale a GameObject to a certain size along the y-axis only + * + * @method LeanTween.scaleY + * @param {GameObject} gameObject:GameObject Gameobject that you wish to scale + * @param {float} scaleTo:float the size with which to scale to + * @param {float} time:float the time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scaleY(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setScaleY() ); + } -/** -* Move a RectTransform object affecting x-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.moveX (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The final x location with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.moveX(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); -*/ -public static LTDescr moveX(RectTransform rectTrans, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_MOVE_X, options().setRect( rectTrans ) ); -} + /** + * Scale a GameObject to a certain size along the z-axis only Scale a GameObject to a certain size along the z-axis only + * + * @method LeanTween.scaleZ + * @param {GameObject} gameObject:GameObject Gameobject that you wish to scale + * @param {float} scaleTo:float the size with which to scale to + * @param {float} time:float the time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr scaleZ(GameObject gameObject, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setScaleZ()); + } -/** -* Move a RectTransform object affecting y-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.moveY (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The final y location with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.moveY(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); -*/ -public static LTDescr moveY(RectTransform rectTrans, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_MOVE_Y, options().setRect( rectTrans ) ); -} + /** + * Tween any particular value (float) Tween any particular value (float) + * + * @method LeanTween.value (float) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {float} from:float The original value to start the tween from + * @param {Vector3} to:float The final float with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( function( val:float ){
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, 1f, 5f, 5f).setOnUpdate( (float val)=>{
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ */ + public static LTDescr value(GameObject gameObject, float from, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setCallback().setFrom( new Vector3(from,0,0) ) ); + } + public static LTDescr value(float from, float to, float time){ + return pushNewTween( tweenEmpty, new Vector3(to,0,0), time, options().setCallback().setFrom( new Vector3(from,0,0) ) ); + } -/** -* Move a RectTransform object affecting z-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.moveZ (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The final x location with which to tween to -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.moveZ(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); -*/ -public static LTDescr moveZ(RectTransform rectTrans, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_MOVE_Z, options().setRect( rectTrans ) ); -} + /** + * Tween any particular value (Vector2) + * + * @method LeanTween.value (Vector2) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Vector2} from:Vector2 The original value to start the tween from + * @param {Vector3} to:Vector2 The final Vector2 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, new Vector2(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( function( val:Vector2 ){
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, new Vector3(1f,0f), new Vector3(5f,0f), 5f).setOnUpdate( (Vector2 val)=>{
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ */ + public static LTDescr value(GameObject gameObject, Vector2 from, Vector2 to, float time){ + return pushNewTween( gameObject, new Vector3(to.x,to.y,0), time, options().setValue3().setTo( new Vector3(to.x,to.y,0f) ).setFrom( new Vector3(from.x,from.y,0) ) ); + } -/** -* Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.rotate (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The degree with which to rotate the RectTransform -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.rotate(gameObject.GetComponent<RectTransform>(), 90f, 1f).setDelay(1f); -*/ -public static LTDescr rotate(RectTransform rectTrans, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_ROTATEAROUND, options().setRect( rectTrans ).setAxis(Vector3.forward) ); -} + /** + * Tween any particular value (Vector3) + * + * @method LeanTween.value (Vector3) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Vector3} from:Vector3 The original value to start the tween from + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( function( val:Vector3 ){
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate( (Vector3 val)=>{
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ */ + public static LTDescr value(GameObject gameObject, Vector3 from, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setValue3().setFrom( from ) ); + } -/** -* Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.rotateAround (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {Vector3} axis:Vector3 The axis in which to rotate the RectTransform (Vector3.forward is most commonly used) -* @param {float} to:float The degree with which to rotate the RectTransform -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.rotateAround(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f); -*/ -public static LTDescr rotateAround(RectTransform rectTrans, Vector3 axis, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_ROTATEAROUND, options().setRect( rectTrans ).setAxis(axis) ); -} + /** + * Tween any particular value (Color) + * + * @method LeanTween.value (Color) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Color} from:Color The original value to start the tween from + * @param {Color} to:Color The final Color with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( function( val:Color ){
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, Color.red, Color.yellow, 5f).setOnUpdate( (Color val)=>{
+ *  Debug.Log("tweened val:"+val);
+ * } );
+ */ + public static LTDescr value(GameObject gameObject, Color from, Color to, float time){ + LTDescr lt = pushNewTween( gameObject, new Vector3(1f, to.a, 0f), time, options().setCallbackColor().setPoint( new Vector3(to.r, to.g, to.b) ) + .setFromColor(from).setHasInitialized(false) ); + + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 + SpriteRenderer ren = gameObject.GetComponent(); + lt.spriteRen = ren; + #endif + return lt; + } -/** -* Rotate a RectTransform object around it's local axis (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.rotateAroundLocal (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {Vector3} axis:Vector3 The local axis in which to rotate the RectTransform (Vector3.forward is most commonly used) -* @param {float} to:float The degree with which to rotate the RectTransform -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.rotateAroundLocal(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f); -*/ -public static LTDescr rotateAroundLocal(RectTransform rectTrans, Vector3 axis, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_ROTATEAROUND_LOCAL, options().setRect( rectTrans ).setAxis(axis) ); -} + /** + * Tween any particular value, it does not need to be tied to any particular type or GameObject + * + * @method LeanTween.value (float) + * @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( float val ){ } + * @param {float} float from The original value to start the tween from + * @param {float} float to The value to end the tween on + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
+ * function updateValueExampleCallback( val:float ){
+ *   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
+ * }
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
+ * void updateValueExampleCallback( float val ){
+ *   Debug.Log("tweened value:"+val+" set this to whatever variable you are tweening...");
+ * }
+ */ + + public static LTDescr value(GameObject gameObject, Action callOnUpdate, float from, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setCallback().setTo( new Vector3(to,0,0) ).setFrom( new Vector3(from,0,0) ).setOnUpdate(callOnUpdate) ); + } -/** -* Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.scale (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The final Vector3 with which to tween to (localScale) -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.scale(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().localScale*2f, 1f).setDelay(1f); -*/ -public static LTDescr scale(RectTransform rectTrans, Vector3 to, float time){ - return pushNewTween( rectTrans.gameObject, to, time, TweenAction.CANVAS_SCALE, options().setRect( rectTrans ) ); -} + /** + * Tweens any float value, it does not need to be tied to any particular type or GameObject + * + * @method LeanTween.value (float) + * @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject + * @param {Action} callOnUpdateRatio:Action Function that's called every Update frame. It must accept two float values ex: function updateValue( float val, float ratio){ } + * @param {float} float from The original value to start the tween from + * @param {float} float to The value to end the tween on + * @param {float} float time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
+ * function updateValueExampleCallback( val:float, ratio:float ){
+ *   Debug.Log("tweened value:"+val+" percent complete:"+ratio*100);
+ * }
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, updateValueExampleCallback, 180f, 270f, 1f).setEase(LeanTweenType.easeOutElastic);
+ * void updateValueExampleCallback( float val, float ratio ){
+ *   Debug.Log("tweened value:"+val+" percent complete:"+ratio*100);
+ * }
+ */ + + public static LTDescr value(GameObject gameObject, Action callOnUpdateRatio, float from, float to, float time) { + return pushNewTween(gameObject, new Vector3(to, 0, 0), time, options().setCallback().setTo(new Vector3(to, 0, 0)).setFrom(new Vector3(from, 0, 0)).setOnUpdateRatio(callOnUpdateRatio)); + } -/** -* Alpha an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.alpha (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The final Vector3 with which to tween to (localScale) -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.alpha(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f); -*/ -public static LTDescr alpha(RectTransform rectTrans, float to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, TweenAction.CANVAS_ALPHA, options().setRect( rectTrans ) ); -} + /** + * Tween from one color to another + * + * @method LeanTween.value (Color) + * @param {GameObject} GameObject gameObject GameObject with which to tie the tweening with. This is only used when you need to cancel this tween, it does not actually perform any operations on this gameObject + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a color value ex: function updateValue( Color val ){ } + * @param {Color} Color from The original value to start the tween from + * @param {Color} Color to The value to end the tween on + * @param {Color} Color time The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example + * Example Javascript:
+ * LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
+ * function updateValueExampleCallback( val:Color ){
+ *   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
+ * }
+ *
+ * Example C#:
+ * LeanTween.value( gameObject, updateValueExampleCallback, Color.red, Color.green, 1f).setEase(LeanTweenType.easeOutElastic);
+ * void updateValueExampleCallback( Color val ){
+ *   Debug.Log("tweened color:"+val+" set this to whatever variable you are tweening...");
+ * }
+ */ + + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Color from, Color to, float time){ + return pushNewTween( gameObject, new Vector3(1.0f,to.a,0.0f), time, options().setCallbackColor().setPoint( new Vector3(to.r, to.g, to.b) ) + .setAxis( new Vector3(from.r, from.g, from.b) ).setFrom( new Vector3(0.0f, from.a, 0.0f) ).setHasInitialized(false).setOnUpdateColor(callOnUpdate) ); + } + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Color from, Color to, float time){ + return pushNewTween( gameObject, new Vector3(1.0f,to.a,0.0f), time, options().setCallbackColor().setPoint( new Vector3(to.r, to.g, to.b) ) + .setAxis( new Vector3(from.r, from.g, from.b) ).setFrom( new Vector3(0.0f, from.a, 0.0f) ).setHasInitialized(false).setOnUpdateColor(callOnUpdate) ); + } -/** -* Change the Color of an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) -* -* @method LeanTween.alpha (RectTransform) -* @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to -* @param {float} to:float The final Vector3 with which to tween to (localScale) -* @param {float} time:float The time to complete the tween in -* @return {LTDescr} LTDescr an object that distinguishes the tween -* @example LeanTween.color(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f); -*/ -public static LTDescr color(RectTransform rectTrans, Color to, float time){ - return pushNewTween( rectTrans.gameObject, new Vector3(1.0f, to.a, 0.0f), time, TweenAction.CANVAS_COLOR, options().setRect( rectTrans ).setPoint( new Vector3(to.r, to.g, to.b) ) ); -} + /** + * Tween any particular value (Vector2), this could be used to tween an arbitrary value like offset property + * + * @method LeanTween.value (Vector2) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ } + * @param {float} from:Vector2 The original value to start the tween from + * @param {Vector2} to:Vector2 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Vector2 from, Vector2 to, float time){ + return pushNewTween( gameObject, new Vector3(to.x,to.y,0f), time, options().setValue3().setTo( new Vector3(to.x,to.y,0f) ).setFrom( new Vector3(from.x,from.y,0f) ).setOnUpdateVector2(callOnUpdate) ); + } -#endif - -#if LEANTWEEN_1 -// LeanTween 1.x Methods - -public static Hashtable h( object[] arr ){ - if(arr.Length%2==1){ - logError("LeanTween - You have attempted to create a Hashtable with an odd number of values."); - return null; - } - Hashtable hash = new Hashtable(); - for(i = 0; i < arr.Length; i += 2){ - hash.Add(arr[i] as string, arr[i+1]); - } - - return hash; -} + /** + * Tween any particular value (Vector3), this could be used to tween an arbitrary property that uses a Vector + * + * @method LeanTween.value (Vector3) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val ){ } + * @param {float} from:Vector3 The original value to start the tween from + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr value(GameObject gameObject, Action callOnUpdate, Vector3 from, Vector3 to, float time){ + return pushNewTween( gameObject, to, time, options().setValue3().setTo( to ).setFrom( from ).setOnUpdateVector3(callOnUpdate) ); + } -private static int idFromUnique( int uniqueId ){ - return uniqueId & 0xFFFF; -} + /** + * Tween any particular value (float) + * + * @method LeanTween.value (float,object) + * @param {GameObject} gameObject:GameObject Gameobject that you wish to attach the tween to + * @param {Action} callOnUpdate:Action The function that is called on every Update frame, this function needs to accept a float value ex: function updateValue( Vector3 val, object obj ){ } + * @param {float} from:float The original value to start the tween from + * @param {Vector3} to:float The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + */ + public static LTDescr value(GameObject gameObject, Action callOnUpdate, float from, float to, float time){ + return pushNewTween( gameObject, new Vector3(to,0,0), time, options().setCallback().setTo( new Vector3(to,0,0) ).setFrom( new Vector3(from,0,0) ).setOnUpdate(callOnUpdate, gameObject) ); + } -private static int pushNewTween( GameObject gameObject, Vector3 to, float time, TweenAction tweenAction, Hashtable optional ){ - init(maxTweens); - if(gameObject==null) - return -1; - - j = 0; - for(i = startSearch; j < maxTweens; i++){ - if(i>=maxTweens-1) - i = 0; - if(tweens[i].toggle==false){ - if(i+1>tweenMaxSearch) - tweenMaxSearch = i+1; - startSearch = i + 1; - break; - } - - j++; - if(j>=maxTweens){ - logError("LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( "+(maxTweens*2)+" );"); - return -1; - } - } - LTDescr tween = tweens[i]; - tween.toggle = true; - tween.reset(); - tween.trans = gameObject.transform; - tween.to = to; - tween.time = time; - tween.type = tweenAction; - tween.optional = optional; - tween.setId( (uint)i ); - //tween.hasPhysics = gameObject.rigidbody!=null; - - if(optional!=null){ - var ease = optional["ease"]; - //LeanTweenType ease; - var optionsNotUsed = 0; - if(ease!=null) { - tween.tweenType = LeanTweenType.linear; - if( ease.GetType() ==typeof( LeanTweenType) ){ - tween.tweenType = (LeanTweenType)ease;// Enum.Parse(typeof(LeanTweenType), optional["ease"].ToString()); - } else if(ease.GetType() == typeof(AnimationCurve)){ - tween.animationCurve = optional["ease"] as AnimationCurve; - } else{ - string func = optional["ease"].ToString(); - if(func.Equals("easeOutQuad")){ - tween.tweenType = LeanTweenType.easeOutQuad; - }else if(func.Equals("easeInQuad")){ - tween.tweenType = LeanTweenType.easeInQuad; - }else if(func.Equals("easeInOutQuad")){ - tween.tweenType = LeanTweenType.easeInOutQuad; - } - } - optionsNotUsed++; - } - if(optional["rect"]!=null){ - tween.ltRect = (LTRect)optional["rect"]; - optionsNotUsed++; - } - if(optional["path"]!=null){ - tween.path = (LTBezierPath)optional["path"]; - optionsNotUsed++; - } - if(optional["delay"]!=null){ - tween.delay = (float)optional["delay"]; - optionsNotUsed++; - } - if(optional["useEstimatedTime"]!=null){ - tween.useEstimatedTime =(bool) optional["useEstimatedTime"]; - optionsNotUsed++; - } - if(optional["useFrames"]!=null){ - tween.useFrames =(bool) optional["useFrames"]; - optionsNotUsed++; - } - if(optional["loopType"]!=null){ - tween.loopType = (LeanTweenType)optional["loopType"]; - optionsNotUsed++; - } - if(optional["repeat"]!=null){ - tween.loopCount = (int)optional["repeat"]; - if(tween.loopType==LeanTweenType.once) - tween.loopType = LeanTweenType.clamp; - optionsNotUsed++; - } - if(optional["point"]!=null){ - tween.point = (Vector3)optional["point"]; - optionsNotUsed++; - } - if(optional["axis"]!=null){ - tween.axis = (Vector3)optional["axis"]; - optionsNotUsed++; - } - if(optional.Count <= optionsNotUsed) - tween.optional = null; // nothing else is used with the extra piece, so set to null - }else{ - tween.optional = null; - } - //Debug.Log("pushing new tween["+i+"]:"+tweens[i]); - - return tweens[i].uniqueId; -} + public static LTDescr delayedSound( AudioClip audio, Vector3 pos, float volume ){ + //Debug.LogError("Delay sound??"); + return pushNewTween( tweenEmpty, pos, 0f, options().setDelayedSound().setTo( pos ).setFrom( new Vector3(volume,0,0) ).setAudio( audio ) ); + } -public static int value(string callOnUpdate, float from, float to, float time, Hashtable optional){ - return value( tweenEmpty, callOnUpdate, from, to, time, optional ); -} -public static int value(GameObject gameObject, string callOnUpdate, float from, float to, float time){ - return value(gameObject, callOnUpdate, from, to, time, new Hashtable()); -} -public static int value(GameObject gameObject, string callOnUpdate, float from, float to, float time, object[] optional){ - return value(gameObject, callOnUpdate, from, to, time, h(optional)); -} -public static int value(GameObject gameObject, Action callOnUpdate, float from, float to, float time, object[] optional){ - return value(gameObject, callOnUpdate, from, to, time, h(optional)); -} -public static int value(GameObject gameObject, Action callOnUpdate, float from, float to, float time, object[] optional){ - return value(gameObject, callOnUpdate, from, to, time, h(optional)); -} -public static int value(GameObject gameObject,string callOnUpdate, float from, float to, float time, Hashtable optional){ - if(optional==null || optional.Count == 0) - optional = new Hashtable(); - - optional["onUpdate"] = callOnUpdate; - int id = idFromUnique( pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.CALLBACK, optional ) ); - tweens[id].from = new Vector3(from,0,0); - return id; -} -public static int value(GameObject gameObject,Action callOnUpdate, float from, float to, float time, Hashtable optional){ - if(optional==null || optional.Count == 0) - optional = new Hashtable(); - - optional["onUpdate"] = callOnUpdate; - int id = idFromUnique( pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.CALLBACK, optional ) ); - tweens[id].from = new Vector3(from,0,0); - return id; -} -public static int value(GameObject gameObject,Action callOnUpdate, float from, float to, float time, Hashtable optional){ - if(optional==null || optional.Count == 0) - optional = new Hashtable(); - - optional["onUpdate"] = callOnUpdate; - int id = idFromUnique( pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.CALLBACK, optional ) ); - tweens[id].from = new Vector3(from,0,0); - return id; -} -public static int value(GameObject gameObject, String callOnUpdate, Vector3 from, Vector3 to, float time, Hashtable optional){ - if(optional==null || optional.Count==0) - optional = new Hashtable(); - - optional["onUpdate"] = callOnUpdate; - int id = idFromUnique( pushNewTween( gameObject, to, time, TweenAction.VALUE3, optional ) ); - tweens[id].from = from; - return id; -} -public static int value(GameObject gameObject, String callOnUpdate, Vector3 from, Vector3 to, float time, object[] optional){ - return value(gameObject, callOnUpdate, from, to, time, h(optional)); -} -public static int value(GameObject gameObject, System.Action callOnUpdate, Vector3 from, Vector3 to, float time, Hashtable optional){ - if(optional==null || optional.Count==0) - optional = new Hashtable(); - - optional["onUpdate"] = callOnUpdate; - int id = idFromUnique( pushNewTween( gameObject, to, time, TweenAction.VALUE3, optional ) ); - tweens[id].from = from; - return id; -} -public static int value(GameObject gameObject, System.Action callOnUpdate, Vector3 from, Vector3 to, float time, Hashtable optional){ - if(optional==null || optional.Count==0) - optional = new Hashtable(); - - optional["onUpdate"] = callOnUpdate; - int id = idFromUnique( pushNewTween( gameObject, to, time, TweenAction.VALUE3, optional ) ); - tweens[id].from = from; - return id; -} -public static int value(GameObject gameObject, System.Action callOnUpdate, Vector3 from, Vector3 to, float time, object[] optional){ - return value(gameObject, callOnUpdate, from, to, time, h(optional)); -} -public static int value(GameObject gameObject, System.Action callOnUpdate, Vector3 from, Vector3 to, float time, object[] optional){ - return value(gameObject, callOnUpdate, from, to, time, h(optional)); -} -public static int rotate(GameObject gameObject, Vector3 to, float time, Hashtable optional){ - return pushNewTween( gameObject, to, time, TweenAction.ROTATE, optional ); -} -public static int rotate(GameObject gameObject, Vector3 to, float time, object[] optional){ - return rotate( gameObject, to, time, h( optional ) ); -} -public static int rotate(LTRect ltRect, float to, float time, Hashtable optional){ - init(); - if( optional==null || optional.Count == 0 ) - optional = new Hashtable(); + public static LTDescr delayedSound( GameObject gameObject, AudioClip audio, Vector3 pos, float volume ){ + //Debug.LogError("Delay sound??"); + return pushNewTween( gameObject, pos, 0f, options().setDelayedSound().setTo( pos ).setFrom( new Vector3(volume,0,0) ).setAudio( audio ) ); + } - optional["rect"] = ltRect; - return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, TweenAction.GUI_ROTATE, optional ); -} -public static int rotate(LTRect ltRect, float to, float time, object[] optional){ - return rotate( ltRect, to, time, h(optional) ); -} -public static int rotateX(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ROTATE_X, optional ); -} -public static int rotateX(GameObject gameObject, float to, float time, object[] optional){ - return rotateX( gameObject, to, time, h(optional) ); -} -public static int rotateY(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ROTATE_Y, optional ); -} -public static int rotateY(GameObject gameObject, float to, float time, object[] optional){ - return rotateY( gameObject, to, time, h(optional) ); -} -public static int rotateZ(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ROTATE_Z, optional ); -} -public static int rotateZ(GameObject gameObject, float to, float time, object[] optional){ - return rotateZ( gameObject, to, time, h(optional) ); -} -public static int rotateLocal(GameObject gameObject, Vector3 to, float time, Hashtable optional){ - return pushNewTween( gameObject, to, time, TweenAction.ROTATE_LOCAL, optional ); -} -public static int rotateLocal(GameObject gameObject, Vector3 to, float time, object[] optional){ - return rotateLocal( gameObject, to, time, h(optional) ); -} -public static int rotateAround(GameObject gameObject, Vector3 axis, float add, float time, Hashtable optional){ - if(optional==null || optional.Count==0) - optional = new Hashtable(); - - optional["axis"] = axis; - if(optional["point"]==null) - optional["point"] = Vector3.zero; - - return pushNewTween( gameObject, new Vector3(add,0f,0f), time, TweenAction.ROTATE_AROUND, optional ); -} -public static int rotateAround(GameObject gameObject, Vector3 axis, float add, float time, object[] optional){ - return rotateAround(gameObject, axis, add, time, h(optional)); -} -public static int moveX(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_X, optional ); -} -public static int moveX(GameObject gameObject, float to, float time, object[] optional){ - return moveX( gameObject, to, time, h(optional) ); -} -public static int moveY(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_Y, optional ); -} -public static int moveY(GameObject gameObject, float to, float time, object[] optional){ - return moveY( gameObject, to, time, h(optional) ); -} -public static int moveZ(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_Z, optional ); -} -public static int moveZ(GameObject gameObject, float to, float time, object[] optional){ - return moveZ( gameObject, to, time, h(optional) ); -} -public static int move(GameObject gameObject, Vector3 to, float time, Hashtable optional){ - return pushNewTween( gameObject, to, time, TweenAction.MOVE, optional ); -} -public static int move(GameObject gameObject, Vector3 to, float time, object[] optional){ - return move( gameObject, to, time, LeanTween.h( optional ) ); -} -public static int move(GameObject gameObject, Vector3[] to, float time, Hashtable optional){ - if(to.Length<4){ - string errorMsg = "LeanTween - When passing values for a vector path, you must pass four or more values!"; - if(throwErrors) Debug.LogError(errorMsg); else Debug.Log(errorMsg); - return -1; - } - if(to.Length%4!=0){ - string errorMsg2 = "LeanTween - When passing values for a vector path, they must be in sets of four: controlPoint1, controlPoint2, endPoint2, controlPoint2, controlPoint2..."; - if(throwErrors) Debug.LogError(errorMsg2); else Debug.Log(errorMsg2); - return -1; - } - - init(); - if( optional==null || optional.Count == 0 ) - optional = new Hashtable(); - - LTBezierPath ltPath = new LTBezierPath( to ); - if(optional["orientToPath"]!=null) - ltPath.orientToPath = true; - optional["path"] = ltPath; - - return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, TweenAction.MOVE_CURVED, optional ); -} -public static int move(GameObject gameObject, Vector3[] to, float time, object[] optional){ - return move( gameObject, to, time, LeanTween.h( optional ) ); -} + #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 -public static int move(LTRect ltRect, Vector2 to, float time, Hashtable optional){ - init(); - if( optional==null || optional.Count == 0 ) - optional = new Hashtable(); + /** + * Move a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Move a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.move (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.move(gameObject.GetComponent<RectTransform>(), new Vector3(200f,-100f,0f), 1f).setDelay(1f); + */ + public static LTDescr move(RectTransform rectTrans, Vector3 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasMove().setRect( rectTrans ) ); + } - optional["rect"] = ltRect; - return pushNewTween( tweenEmpty, to, time, TweenAction.GUI_MOVE, optional ); -} -public static int move(LTRect ltRect, Vector3 to, float time, object[] optional){ - return move( ltRect, to, time, LeanTween.h( optional ) ); -} - -public static int moveLocal(GameObject gameObject, Vector3 to, float time, Hashtable optional){ - return pushNewTween( gameObject, to, time, TweenAction.MOVE_LOCAL, optional ); -} -public static int moveLocal(GameObject gameObject, Vector3 to, float time, object[] optional){ - return moveLocal( gameObject, to, time, LeanTween.h( optional ) ); -} + /** + * Move a RectTransform object affecting x-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Move a RectTransform object affecting x-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.moveX (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final x location with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.moveX(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); + */ + public static LTDescr moveX(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasMoveX().setRect( rectTrans ) ); + } -public static int moveLocal(GameObject gameObject, Vector3[] to, float time, Hashtable optional){ - if(to.Length<4){ - string errorMsg = "LeanTween - When passing values for a vector path, you must pass four or more values!"; - if(throwErrors) Debug.LogError(errorMsg); else Debug.Log(errorMsg); - return -1; - } - if(to.Length%4!=0){ - string errorMsg2 = "LeanTween - When passing values for a vector path, they must be in sets of four: controlPoint1, controlPoint2, endPoint2, controlPoint2, controlPoint2..."; - if(throwErrors) Debug.LogError(errorMsg2); else Debug.Log(errorMsg2); - return -1; - } - - init(); - if( optional == null ) - optional = new Hashtable(); - - LTBezierPath ltPath = new LTBezierPath( to ); - if(optional["orientToPath"]!=null) - ltPath.orientToPath = true; - optional["path"] = ltPath; - - return pushNewTween( gameObject, new Vector3(1.0f,0.0f,0.0f), time, TweenAction.MOVE_CURVED_LOCAL, optional ); -} -public static int moveLocal(GameObject gameObject, Vector3[] to, float time,object[] optional){ - return moveLocal( gameObject, to, time, LeanTween.h( optional ) ); -} -public static int moveLocalX(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_LOCAL_X, optional ); -} -public static int moveLocalX(GameObject gameObject, float to, float time, object[] optional){ - return moveLocalX( gameObject, to, time, h(optional) ); -} -public static int moveLocalY(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_LOCAL_Y, optional ); -} -public static int moveLocalY(GameObject gameObject, float to, float time, object[] optional){ - return moveLocalY( gameObject, to, time, h(optional) ); -} -public static int moveLocalZ(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.MOVE_LOCAL_Z, optional ); -} -public static int moveLocalZ(GameObject gameObject, float to, float time, object[] optional){ - return moveLocalZ( gameObject, to, time, h(optional) ); -} -public static int scale(GameObject gameObject, Vector3 to, float time, Hashtable optional){ - return pushNewTween( gameObject, to, time, TweenAction.SCALE, optional ); -} -public static int scale(GameObject gameObject, Vector3 to, float time, object[] optional){ - return scale( gameObject, to, time, h(optional) ); -} -public static int scale(LTRect ltRect,Vector2 to, float time, Hashtable optional) -{ - init(); - if( optional==null || optional.Count == 0 ) - optional = new Hashtable(); - - optional["rect"] = ltRect; - return pushNewTween( tweenEmpty, to, time, TweenAction.GUI_SCALE, optional ); -} -public static int scale(LTRect ltRect, Vector2 to, float time, object[] optional){ - return scale( ltRect, to, time, h(optional) ); -} -public static int alpha(LTRect ltRect, float to, float time, Hashtable optional){ - init(); - if( optional==null || optional.Count == 0 ) - optional = new Hashtable(); - - ltRect.alphaEnabled = true; - optional["rect"] = ltRect; - return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, TweenAction.GUI_ALPHA, optional ); -} -public static int alpha(LTRect ltRect, float to, float time, object[] optional){ - return alpha( ltRect, to, time, h(optional) ); -} -public static int scaleX(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.SCALE_X, optional ); -} -public static int scaleX(GameObject gameObject, float to, float time, object[] optional){ - return scaleX( gameObject, to, time, h(optional) ); -} -public static int scaleY(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.SCALE_Y, optional ); -} -public static int scaleY(GameObject gameObject, float to, float time, object[] optional){ - return scaleY( gameObject, to, time, h(optional) ); -} -public static int scaleZ(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.SCALE_Z, optional ); -} -public static int scaleZ(GameObject gameObject, float to, float time, object[] optional){ - return scaleZ( gameObject, to, time, h(optional) ); -} -public static int delayedCall( float delayTime, string callback, Hashtable optional ){ - init(); - return delayedCall( tweenEmpty, delayTime, callback, optional ); -} -public static int delayedCall( float delayTime, Action callback, object[] optional){ - init(); - return delayedCall( tweenEmpty, delayTime, callback, h(optional) ); -} -public static int delayedCall( GameObject gameObject, float delayTime, string callback, object[] optional){ - return delayedCall( gameObject, delayTime, callback, h(optional) ); -} -public static int delayedCall( GameObject gameObject, float delayTime, Action callback, object[] optional){ - return delayedCall( gameObject, delayTime, callback, h(optional) ); -} -public static int delayedCall( GameObject gameObject, float delayTime, string callback, Hashtable optional){ - if(optional==null || optional.Count == 0) - optional = new Hashtable(); - optional["onComplete"] = callback; + /** + * Move a RectTransform object affecting y-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Move a RectTransform object affecting y-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.moveY (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final y location with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.moveY(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); + */ + public static LTDescr moveY(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasMoveY().setRect( rectTrans ) ); + } - return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, optional ); -} -public static int delayedCall( GameObject gameObject, float delayTime, Action callback, Hashtable optional){ - if(optional==null) - optional = new Hashtable(); - optional["onComplete"] = callback; + /** + * Move a RectTransform object affecting z-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Move a RectTransform object affecting z-axis only (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...)n + * + * @method LeanTween.moveZ (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final x location with which to tween to + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.moveZ(gameObject.GetComponent<RectTransform>(), 200f, 1f).setDelay(1f); + */ + public static LTDescr moveZ(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasMoveZ().setRect( rectTrans ) ); + } - return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, optional ); -} -public static int delayedCall( GameObject gameObject, float delayTime, Action callback, Hashtable optional){ - if(optional==null) - optional = new Hashtable(); - optional["onComplete"] = callback; + /** + * Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.rotate (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The degree with which to rotate the RectTransform + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotate(gameObject.GetComponent<RectTransform>(), 90f, 1f).setDelay(1f); + */ + public static LTDescr rotate(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasRotateAround().setRect( rectTrans ).setAxis(Vector3.forward) ); + } - return pushNewTween( gameObject, Vector3.zero, delayTime, TweenAction.CALLBACK, optional ); -} -public static int alpha(GameObject gameObject, float to, float time, Hashtable optional){ - return pushNewTween( gameObject, new Vector3(to,0,0), time, TweenAction.ALPHA, optional ); -} -public static int alpha(GameObject gameObject, float to, float time, object[] optional){ - return alpha(gameObject, to, time, h(optional)); -} -#endif + public static LTDescr rotate(RectTransform rectTrans, Vector3 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasRotateAround().setRect( rectTrans ).setAxis(Vector3.forward) ); + } -// Tweening Functions - Thanks to Robert Penner and GFX47 + /** + * Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Rotate a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.rotateAround (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} axis:Vector3 The axis in which to rotate the RectTransform (Vector3.forward is most commonly used) + * @param {float} to:float The degree with which to rotate the RectTransform + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotateAround(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f); + */ + public static LTDescr rotateAround(RectTransform rectTrans, Vector3 axis, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasRotateAround().setRect( rectTrans ).setAxis(axis) ); + } -private static float tweenOnCurve( LTDescr tweenDescr, float ratioPassed ){ - // Debug.Log("single ratio:"+ratioPassed+" tweenDescr.animationCurve.Evaluate(ratioPassed):"+tweenDescr.animationCurve.Evaluate(ratioPassed)); - return tweenDescr.from.x + (tweenDescr.diff.x) * tweenDescr.animationCurve.Evaluate(ratioPassed); -} + /** + * Rotate a RectTransform object around it's local axis (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Rotate a RectTransform object around it's local axis (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.rotateAroundLocal (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} axis:Vector3 The local axis in which to rotate the RectTransform (Vector3.forward is most commonly used) + * @param {float} to:float The degree with which to rotate the RectTransform + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.rotateAroundLocal(gameObject.GetComponent<RectTransform>(), Vector3.forward, 90f, 1f).setDelay(1f); + */ + public static LTDescr rotateAroundLocal(RectTransform rectTrans, Vector3 axis, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasRotateAroundLocal().setRect( rectTrans ).setAxis(axis) ); + } -private static Vector3 tweenOnCurveVector( LTDescr tweenDescr, float ratioPassed ){ - return new Vector3(tweenDescr.from.x + (tweenDescr.diff.x) * tweenDescr.animationCurve.Evaluate(ratioPassed), - tweenDescr.from.y + (tweenDescr.diff.y) * tweenDescr.animationCurve.Evaluate(ratioPassed), - tweenDescr.from.z + (tweenDescr.diff.z) * tweenDescr.animationCurve.Evaluate(ratioPassed) ); -} + /** + * Scale a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Scale a RectTransform object (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.scale (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector3} to:Vector3 The final Vector3 with which to tween to (localScale) + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.scale(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().localScale*2f, 1f).setDelay(1f); + */ + public static LTDescr scale(RectTransform rectTrans, Vector3 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasScale().setRect( rectTrans ) ); + } -private static float easeOutQuadOpt( float start, float diff, float ratioPassed ){ - return -diff * ratioPassed * (ratioPassed - 2) + start; -} + /** + * Change the sizeDelta of a RectTransform object (used in Unity Canvas, for Buttons, Panel, Scrollbar, etc...) Change the sizeDelta of a RectTransform object (used in Unity Canvas, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.size (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {Vector2} to:Vector2 The final Vector2 the tween will end at for sizeDelta property + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.size(gameObject.GetComponent<RectTransform>(), gameObject.GetComponent<RectTransform>().sizeDelta*2f, 1f).setDelay(1f); + */ + public static LTDescr size(RectTransform rectTrans, Vector2 to, float time){ + return pushNewTween( rectTrans.gameObject, to, time, options().setCanvasSizeDelta().setRect( rectTrans ) ); + } -private static float easeInQuadOpt( float start, float diff, float ratioPassed ){ - return diff * ratioPassed * ratioPassed + start; -} + /** + * Alpha an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Alpha an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.alpha (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final Vector3 with which to tween to (localScale) + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.alpha(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f); + */ + public static LTDescr alpha(RectTransform rectTrans, float to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(to,0f,0f), time, options().setCanvasAlpha().setRect( rectTrans ) ); + } -private static float easeInOutQuadOpt( float start, float diff, float ratioPassed ){ - ratioPassed /= .5f; - if (ratioPassed < 1) return diff / 2 * ratioPassed * ratioPassed + start; - ratioPassed--; - return -diff / 2 * (ratioPassed * (ratioPassed - 2) - 1) + start; -} + /** + * Change the Color of an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) Change the Color of an Image Component attached to a RectTransform (used in Unity GUI in 4.6+, for Buttons, Panel, Scrollbar, etc...) + * + * @method LeanTween.alpha (RectTransform) + * @param {RectTransform} rectTrans:RectTransform RectTransform that you wish to attach the tween to + * @param {float} to:float The final Vector3 with which to tween to (localScale) + * @param {float} time:float The time to complete the tween in + * @return {LTDescr} LTDescr an object that distinguishes the tween + * @example LeanTween.color(gameObject.GetComponent<RectTransform>(), 0.5f, 1f).setDelay(1f); + */ + public static LTDescr color(RectTransform rectTrans, Color to, float time){ + return pushNewTween( rectTrans.gameObject, new Vector3(1.0f, to.a, 0.0f), time, options().setCanvasColor().setRect( rectTrans ).setPoint( new Vector3(to.r, to.g, to.b) ) ); + } -private static float linear(float start, float end, float val){ - return Mathf.Lerp(start, end, val); -} + #endif -private static float clerp(float start, float end, float val){ - float min = 0.0f; - float max = 360.0f; - float half = Mathf.Abs((max - min) / 2.0f); - float retval = 0.0f; - float diff = 0.0f; - if ((end - start) < -half){ - diff = ((max - start) + end) * val; - retval = start + diff; - }else if ((end - start) > half){ - diff = -((max - end) + start) * val; - retval = start + diff; - }else retval = start + (end - start) * val; - return retval; -} + // Tweening Functions - Thanks to Robert Penner and GFX47 -private static float spring(float start, float end, float val ){ - val = Mathf.Clamp01(val); - val = (Mathf.Sin(val * Mathf.PI * (0.2f + 2.5f * val * val * val)) * Mathf.Pow(1f - val, 2.2f ) + val) * (1f + (1.2f * (1f - val) )); - return start + (end - start) * val; -} + public static float tweenOnCurve( LTDescr tweenDescr, float ratioPassed ){ + // Debug.Log("single ratio:"+ratioPassed+" tweenDescr.animationCurve.Evaluate(ratioPassed):"+tweenDescr.animationCurve.Evaluate(ratioPassed)); + return tweenDescr.from.x + (tweenDescr.diff.x) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed); + } -private static float easeInQuad(float start, float end, float val){ - end -= start; - return end * val * val + start; -} + public static Vector3 tweenOnCurveVector( LTDescr tweenDescr, float ratioPassed ){ + return new Vector3(tweenDescr.from.x + (tweenDescr.diff.x) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed), + tweenDescr.from.y + (tweenDescr.diff.y) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed), + tweenDescr.from.z + (tweenDescr.diff.z) * tweenDescr.optional.animationCurve.Evaluate(ratioPassed) ); + } -private static float easeOutQuad(float start, float end, float val){ - end -= start; - return -end * val * (val - 2) + start; -} + public static float easeOutQuadOpt( float start, float diff, float ratioPassed ){ + return -diff * ratioPassed * (ratioPassed - 2) + start; + } -private static float easeInOutQuad(float start, float end, float val){ - val /= .5f; - end -= start; - if (val < 1) return end / 2 * val * val + start; - val--; - return -end / 2 * (val * (val - 2) - 1) + start; -} + public static float easeInQuadOpt( float start, float diff, float ratioPassed ){ + return diff * ratioPassed * ratioPassed + start; + } -private static float easeInCubic(float start, float end, float val){ - end -= start; - return end * val * val * val + start; -} + public static float easeInOutQuadOpt( float start, float diff, float ratioPassed ){ + ratioPassed /= .5f; + if (ratioPassed < 1) return diff / 2 * ratioPassed * ratioPassed + start; + ratioPassed--; + return -diff / 2 * (ratioPassed * (ratioPassed - 2) - 1) + start; + } -private static float easeOutCubic(float start, float end, float val){ - val--; - end -= start; - return end * (val * val * val + 1) + start; -} + public static Vector3 easeInOutQuadOpt( Vector3 start, Vector3 diff, float ratioPassed ){ + ratioPassed /= .5f; + if (ratioPassed < 1) return diff / 2 * ratioPassed * ratioPassed + start; + ratioPassed--; + return -diff / 2 * (ratioPassed * (ratioPassed - 2) - 1) + start; + } -private static float easeInOutCubic(float start, float end, float val){ - val /= .5f; - end -= start; - if (val < 1) return end / 2 * val * val * val + start; - val -= 2; - return end / 2 * (val * val * val + 2) + start; -} + public static float linear(float start, float end, float val){ + return Mathf.Lerp(start, end, val); + } -private static float easeInQuart(float start, float end, float val){ - end -= start; - return end * val * val * val * val + start; -} + public static float clerp(float start, float end, float val){ + float min = 0.0f; + float max = 360.0f; + float half = Mathf.Abs((max - min) / 2.0f); + float retval = 0.0f; + float diff = 0.0f; + if ((end - start) < -half){ + diff = ((max - start) + end) * val; + retval = start + diff; + }else if ((end - start) > half){ + diff = -((max - end) + start) * val; + retval = start + diff; + }else retval = start + (end - start) * val; + return retval; + } -private static float easeOutQuart(float start, float end, float val){ - val--; - end -= start; - return -end * (val * val * val * val - 1) + start; -} + public static float spring(float start, float end, float val ){ + val = Mathf.Clamp01(val); + val = (Mathf.Sin(val * Mathf.PI * (0.2f + 2.5f * val * val * val)) * Mathf.Pow(1f - val, 2.2f ) + val) * (1f + (1.2f * (1f - val) )); + return start + (end - start) * val; + } + + public static float easeInQuad(float start, float end, float val){ + end -= start; + return end * val * val + start; + } + + public static float easeOutQuad(float start, float end, float val){ + end -= start; + return -end * val * (val - 2) + start; + } + + public static float easeInOutQuad(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val + start; + val--; + return -end / 2 * (val * (val - 2) - 1) + start; + } + + + public static float easeInOutQuadOpt2(float start, float diffBy2, float val, float val2){ + val /= .5f; + if (val < 1) return diffBy2 * val2 + start; + val--; + return -diffBy2 * ((val2 - 2) - 1f) + start; + } + + public static float easeInCubic(float start, float end, float val){ + end -= start; + return end * val * val * val + start; + } + + public static float easeOutCubic(float start, float end, float val){ + val--; + end -= start; + return end * (val * val * val + 1) + start; + } + + public static float easeInOutCubic(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val * val + start; + val -= 2; + return end / 2 * (val * val * val + 2) + start; + } + + public static float easeInQuart(float start, float end, float val){ + end -= start; + return end * val * val * val * val + start; + } + + public static float easeOutQuart(float start, float end, float val){ + val--; + end -= start; + return -end * (val * val * val * val - 1) + start; + } + + public static float easeInOutQuart(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val * val * val + start; + val -= 2; + return -end / 2 * (val * val * val * val - 2) + start; + } + + public static float easeInQuint(float start, float end, float val){ + end -= start; + return end * val * val * val * val * val + start; + } + + public static float easeOutQuint(float start, float end, float val){ + val--; + end -= start; + return end * (val * val * val * val * val + 1) + start; + } + + public static float easeInOutQuint(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * val * val * val * val * val + start; + val -= 2; + return end / 2 * (val * val * val * val * val + 2) + start; + } + + public static float easeInSine(float start, float end, float val){ + end -= start; + return -end * Mathf.Cos(val / 1 * (Mathf.PI / 2)) + end + start; + } + + public static float easeOutSine(float start, float end, float val){ + end -= start; + return end * Mathf.Sin(val / 1 * (Mathf.PI / 2)) + start; + } + + public static float easeInOutSine(float start, float end, float val){ + end -= start; + return -end / 2 * (Mathf.Cos(Mathf.PI * val / 1) - 1) + start; + } + + public static float easeInExpo(float start, float end, float val){ + end -= start; + return end * Mathf.Pow(2, 10 * (val / 1 - 1)) + start; + } + + public static float easeOutExpo(float start, float end, float val){ + end -= start; + return end * (-Mathf.Pow(2, -10 * val / 1) + 1) + start; + } + + public static float easeInOutExpo(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return end / 2 * Mathf.Pow(2, 10 * (val - 1)) + start; + val--; + return end / 2 * (-Mathf.Pow(2, -10 * val) + 2) + start; + } + + public static float easeInCirc(float start, float end, float val){ + end -= start; + return -end * (Mathf.Sqrt(1 - val * val) - 1) + start; + } + + public static float easeOutCirc(float start, float end, float val){ + val--; + end -= start; + return end * Mathf.Sqrt(1 - val * val) + start; + } + + public static float easeInOutCirc(float start, float end, float val){ + val /= .5f; + end -= start; + if (val < 1) return -end / 2 * (Mathf.Sqrt(1 - val * val) - 1) + start; + val -= 2; + return end / 2 * (Mathf.Sqrt(1 - val * val) + 1) + start; + } + + public static float easeInBounce(float start, float end, float val){ + end -= start; + float d = 1f; + return end - easeOutBounce(0, end, d-val) + start; + } + + public static float easeOutBounce(float start, float end, float val){ + val /= 1f; + end -= start; + if (val < (1 / 2.75f)){ + return end * (7.5625f * val * val) + start; + }else if (val < (2 / 2.75f)){ + val -= (1.5f / 2.75f); + return end * (7.5625f * (val) * val + .75f) + start; + }else if (val < (2.5 / 2.75)){ + val -= (2.25f / 2.75f); + return end * (7.5625f * (val) * val + .9375f) + start; + }else{ + val -= (2.625f / 2.75f); + return end * (7.5625f * (val) * val + .984375f) + start; + } + } + + public static float easeInOutBounce(float start, float end, float val){ + end -= start; + float d= 1f; + if (val < d/2) return easeInBounce(0, end, val*2) * 0.5f + start; + else return easeOutBounce(0, end, val*2-d) * 0.5f + end*0.5f + start; + } + + public static float easeInBack(float start, float end, float val, float overshoot = 1.0f){ + end -= start; + val /= 1; + float s= 1.70158f * overshoot; + return end * (val) * val * ((s + 1) * val - s) + start; + } + + public static float easeOutBack(float start, float end, float val, float overshoot = 1.0f){ + float s = 1.70158f * overshoot; + end -= start; + val = (val / 1) - 1; + return end * ((val) * val * ((s + 1) * val + s) + 1) + start; + } + + public static float easeInOutBack(float start, float end, float val, float overshoot = 1.0f){ + float s = 1.70158f * overshoot; + end -= start; + val /= .5f; + if ((val) < 1){ + s *= (1.525f) * overshoot; + return end / 2 * (val * val * (((s) + 1) * val - s)) + start; + } + val -= 2; + s *= (1.525f) * overshoot; + return end / 2 * ((val) * val * (((s) + 1) * val + s) + 2) + start; + } + + public static float easeInElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f){ + end -= start; + + float p = period; + float s = 0f; + float a = 0f; + + if (val == 0f) return start; + + if (val == 1f) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4f; + }else{ + s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); + } + + if(overshoot>1f && val>0.6f ) + overshoot = 1f + ((1f-val) / 0.4f * (overshoot-1f)); + // Debug.Log("ease in elastic val:"+val+" a:"+a+" overshoot:"+overshoot); + + val = val-1f; + return start-(a * Mathf.Pow(2f, 10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p)) * overshoot; + } + + public static float easeOutElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f){ + end -= start; + + float p = period; + float s = 0f; + float a = 0f; + + if (val == 0f) return start; + + // Debug.Log("ease out elastic val:"+val+" a:"+a); + if (val == 1f) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4f; + }else{ + s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); + } + if(overshoot>1f && val<0.4f ) + overshoot = 1f + (val / 0.4f * (overshoot-1f)); + // Debug.Log("ease out elastic val:"+val+" a:"+a+" overshoot:"+overshoot); + + return start + end + a * Mathf.Pow(2f, -10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p) * overshoot; + } + + public static float easeInOutElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f) + { + end -= start; -private static float easeInOutQuart(float start, float end, float val){ - val /= .5f; - end -= start; - if (val < 1) return end / 2 * val * val * val * val + start; - val -= 2; - return -end / 2 * (val * val * val * val - 2) + start; + float p = period; + float s = 0f; + float a = 0f; + + if (val == 0f) return start; + + val = val / (1f/2f); + if (val == 2f) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4f; + }else{ + s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); + } + + if(overshoot>1f){ + if( val<0.2f ){ + overshoot = 1f + (val / 0.2f * (overshoot-1f)); + }else if( val > 0.8f ){ + overshoot = 1f + ((1f-val) / 0.2f * (overshoot-1f)); + } + } + + if (val < 1f){ + val = val-1f; + return start - 0.5f * (a * Mathf.Pow(2f, 10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p)) * overshoot; + } + val = val-1f; + return end + start + a * Mathf.Pow(2f, -10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p) * 0.5f * overshoot; + } + + // LeanTween Listening/Dispatch + + private static System.Action[] eventListeners; + private static GameObject[] goListeners; + private static int eventsMaxSearch = 0; + public static int EVENTS_MAX = 10; + public static int LISTENERS_MAX = 10; + private static int INIT_LISTENERS_MAX = LISTENERS_MAX; + + public static void addListener( int eventId, System.Action callback ){ + addListener(tweenEmpty, eventId, callback); + } + + /** + * Add a listener method to be called when the appropriate LeanTween.dispatchEvent is called + * + * @method LeanTween.addListener + * @param {GameObject} caller:GameObject the gameObject the listener is attached to + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @param {System.Action} callback:System.Action the method to call when the event has been dispatched + * @example + * LeanTween.addListener(gameObject, (int)MyEvents.JUMP, jumpUp);
+ *
+ * void jumpUp( LTEvent e ){ Debug.Log("jump!"); }
+ */ + public static void addListener( GameObject caller, int eventId, System.Action callback ){ + if(eventListeners==null){ + INIT_LISTENERS_MAX = LISTENERS_MAX; + eventListeners = new System.Action[ EVENTS_MAX * LISTENERS_MAX ]; + goListeners = new GameObject[ EVENTS_MAX * LISTENERS_MAX ]; + } + // Debug.Log("searching for an empty space for:"+caller + " eventid:"+event); + for(i = 0; i < INIT_LISTENERS_MAX; i++){ + int point = eventId*INIT_LISTENERS_MAX + i; + if(goListeners[ point ]==null || eventListeners[ point ]==null){ + eventListeners[ point ] = callback; + goListeners[ point ] = caller; + if(i>=eventsMaxSearch) + eventsMaxSearch = i+1; + // Debug.Log("adding event for:"+caller.name); + + return; + } + #if UNITY_FLASH + if(goListeners[ point ] == caller && System.Object.ReferenceEquals( eventListeners[ point ], callback)){ + // Debug.Log("This event is already being listened for."); + return; + } + #else + if(goListeners[ point ] == caller && System.Object.Equals( eventListeners[ point ], callback)){ + // Debug.Log("This event is already being listened for."); + return; + } + #endif + } + Debug.LogError("You ran out of areas to add listeners, consider increasing LISTENERS_MAX, ex: LeanTween.LISTENERS_MAX = "+(LISTENERS_MAX*2)); + } + + public static bool removeListener( int eventId, System.Action callback ){ + return removeListener( tweenEmpty, eventId, callback); + } + + public static bool removeListener( int eventId ){ + int point = eventId*INIT_LISTENERS_MAX + i; + eventListeners[ point ] = null; + goListeners[ point ] = null; + return true; + } + + + /** + * Remove an event listener you have added + * @method LeanTween.removeListener + * @param {GameObject} caller:GameObject the gameObject the listener is attached to + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @param {System.Action} callback:System.Action the method that was specified to call when the event has been dispatched + * @example + * LeanTween.removeListener(gameObject, (int)MyEvents.JUMP, jumpUp);
+ *
+ * void jumpUp( LTEvent e ){ }
+ */ + public static bool removeListener( GameObject caller, int eventId, System.Action callback ){ + for(i = 0; i < eventsMaxSearch; i++){ + int point = eventId*INIT_LISTENERS_MAX + i; + #if UNITY_FLASH + if(goListeners[ point ] == caller && System.Object.ReferenceEquals( eventListeners[ point ], callback) ){ + #else + if(goListeners[ point ] == caller && System.Object.Equals( eventListeners[ point ], callback) ){ + #endif + eventListeners[ point ] = null; + goListeners[ point ] = null; + return true; + } + } + return false; + } + + /** + * Tell the added listeners that you are dispatching the event + * @method LeanTween.dispatchEvent + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @example + * LeanTween.dispatchEvent( (int)MyEvents.JUMP );
+ */ + public static void dispatchEvent( int eventId ){ + dispatchEvent( eventId, null); + } + + /** + * Tell the added listeners that you are dispatching the event + * @method LeanTween.dispatchEvent + * @param {int} eventId:int a unique int that describes the event (best to use an enum) + * @param {object} data:object Pass data to the listener, access it from the listener with *.data on the LTEvent object + * @example + * LeanTween.dispatchEvent( (int)MyEvents.JUMP, transform );
+ *
+ * void jumpUp( LTEvent e ){
+ *   Transform tran = (Transform)e.data;
+ * }
+ */ + public static void dispatchEvent( int eventId, object data ){ + for(int k = 0; k < eventsMaxSearch; k++){ + int point = eventId*INIT_LISTENERS_MAX + k; + if(eventListeners[ point ]!=null){ + if(goListeners[point]){ + eventListeners[ point ]( new LTEvent(eventId, data) ); + }else{ + eventListeners[ point ] = null; + } + } + } + } + + +} // End LeanTween class + +public class LTUtility { + + public static Vector3[] reverse( Vector3[] arr ){ + int length = arr.Length; + int left = 0; + int right = length - 1; + + for (; left < right; left += 1, right -= 1){ + Vector3 temporary = arr[left]; + arr[left] = arr[right]; + arr[right] = temporary; + } + return arr; + } } -private static float easeInQuint(float start, float end, float val){ - end -= start; - return end * val * val * val * val * val + start; +public class LTBezier { + public float length; + + private Vector3 a; + private Vector3 aa; + private Vector3 bb; + private Vector3 cc; + private float len; + private float[] arcLengths; + + public LTBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float precision){ + this.a = a; + aa = (-a + 3*(b-c) + d); + bb = 3*(a+c) - 6*b; + cc = 3*(b-a); + + this.len = 1.0f / precision; + arcLengths = new float[(int)this.len + (int)1]; + arcLengths[0] = 0; + + Vector3 ov = a; + Vector3 v; + float clen = 0.0f; + for(int i = 1; i <= this.len; i++) { + v = bezierPoint(i * precision); + clen += (ov - v).magnitude; + this.arcLengths[i] = clen; + ov = v; + } + this.length = clen; + } + + private float map(float u) { + float targetLength = u * this.arcLengths[(int)this.len]; + int low = 0; + int high = (int)this.len; + int index = 0; + while (low < high) { + index = low + ((int)((high - low) / 2.0f) | 0); + if (this.arcLengths[index] < targetLength) { + low = index + 1; + } else { + high = index; + } + } + if(this.arcLengths[index] > targetLength) + index--; + if(index<0) + index = 0; + + return (index + (targetLength - arcLengths[index]) / (arcLengths[index + 1] - arcLengths[index])) / this.len; + } + + private Vector3 bezierPoint(float t){ + return ((aa* t + (bb))* t + cc)* t + a; + } + + public Vector3 point(float t){ + return bezierPoint( map(t) ); + } } -private static float easeOutQuint(float start, float end, float val){ - val--; - end -= start; - return end * (val * val * val * val * val + 1) + start; +/** +* Manually animate along a bezier path with this class +* @class LTBezierPath +* @constructor +* @param {Vector3 Array} pts A set of points that define one or many bezier paths (the paths should be passed in multiples of 4, which correspond to each individual bezier curve)
+* It goes in the order: startPoint,endControl,startControl,endPoint - Note: the control for the end and start are reversed! This is just a *quirk* of the API.
+* +* @example +* LTBezierPath ltPath = new LTBezierPath( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(1f,0f,0f), new Vector3(1f,0f,0f), new Vector3(1f,1f,0f)} );

+* LeanTween.move(lt, ltPath.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
+* Vector3 pt = ltPath.point( 0.6f ); // retrieve a point along the path +*/ +public class LTBezierPath { + public Vector3[] pts; + public float length; + public bool orientToPath; + public bool orientToPath2d; + + private LTBezier[] beziers; + private float[] lengthRatio; + private int currentBezier=0,previousBezier=0; + + public LTBezierPath(){ } + public LTBezierPath( Vector3[] pts_ ){ + setPoints( pts_ ); + } + + public void setPoints( Vector3[] pts_ ){ + if(pts_.Length<4) + LeanTween.logError( "LeanTween - When passing values for a vector path, you must pass four or more values!" ); + if(pts_.Length%4!=0) + LeanTween.logError( "LeanTween - When passing values for a vector path, they must be in sets of four: controlPoint1, controlPoint2, endPoint2, controlPoint2, controlPoint2..." ); + + pts = pts_; + + int k = 0; + beziers = new LTBezier[ pts.Length / 4 ]; + lengthRatio = new float[ beziers.Length ]; + int i; + length = 0; + for(i = 0; i < pts.Length; i+=4){ + beziers[k] = new LTBezier(pts[i+0],pts[i+2],pts[i+1],pts[i+3],0.05f); + length += beziers[k].length; + k++; + } + // Debug.Log("beziers.Length:"+beziers.Length + " beziers:"+beziers); + for(i = 0; i < beziers.Length; i++){ + lengthRatio[i] = beziers[i].length / length; + } + } + + /** + * @property {float} distance distance of the path (in unity units) + */ + public float distance{ + get{ + return length; + } + } + + /** + * Retrieve a point along a path Move a GameObject to a certain location + * + * @method point + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @return {Vector3} Vector3 position of the point along the path + * @example + * transform.position = ltPath.point( 0.6f ); + */ + public Vector3 point( float ratio ){ + float added = 0.0f; + for(int i = 0; i < lengthRatio.Length; i++){ + added += lengthRatio[i]; + if(added >= ratio) + return beziers[i].point( (ratio-(added-lengthRatio[i])) / lengthRatio[i] ); + } + return beziers[lengthRatio.Length-1].point( 1.0f ); + } + + public void place2d( Transform transform, float ratio ){ + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 v3Dir = point( ratio ) - transform.position; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.eulerAngles = new Vector3(0, 0, angle); + } + } + + public void placeLocal2d( Transform transform, float ratio ){ + transform.localPosition = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 v3Dir = point( ratio ) - transform.localPosition; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.localEulerAngles = new Vector3(0, 0, angle); + } + } + + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) Move a GameObject to a certain location + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.place( transform, 0.6f ); + */ + public void place( Transform transform, float ratio ){ + place( transform, ratio, Vector3.up ); + + } + + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path Move a GameObject to a certain location + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.place( transform, 0.6f, Vector3.left ); + */ + public void place( Transform transform, float ratio, Vector3 worldUp ){ + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f) + transform.LookAt( point( ratio ), worldUp ); + + } + + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space Move a GameObject to a certain location + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.placeLocal( transform, 0.6f ); + */ + public void placeLocal( Transform transform, float ratio ){ + placeLocal( transform, ratio, Vector3.up ); + } + + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space Move a GameObject to a certain location + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.placeLocal( transform, 0.6f, Vector3.left ); + */ + public void placeLocal( Transform transform, float ratio, Vector3 worldUp ){ + // Debug.Log("place ratio:" + ratio + " greater:"+(ratio>1f)); + ratio = Mathf.Clamp01(ratio); + transform.localPosition = point( ratio ); + // Debug.Log("ratio:" + ratio + " +:" + (ratio + 0.001f)); + ratio = Mathf.Clamp01(ratio + 0.001f); + + if(ratio<=1.0f) + transform.LookAt( transform.parent.TransformPoint( point( ratio ) ), worldUp ); + } + + public void gizmoDraw(float t = -1.0f) + { + Vector3 prevPt = point(0); + + for (int i = 1; i <= 120; i++) + { + float pm = (float)i / 120f; + Vector3 currPt2 = point(pm); + //Gizmos.color = new Color(UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),1); + Gizmos.color = (previousBezier == currentBezier) ? Color.magenta : Color.grey; + Gizmos.DrawLine(currPt2, prevPt); + prevPt = currPt2; + previousBezier = currentBezier; + } + } } -private static float easeInOutQuint(float start, float end, float val){ - val /= .5f; - end -= start; - if (val < 1) return end / 2 * val * val * val * val * val + start; - val -= 2; - return end / 2 * (val * val * val * val * val + 2) + start; -} +/** +* Animate along a set of points that need to be in the format: controlPoint, point1, point2.... pointLast, endControlPoint Move a GameObject to a certain location +* @class LTSpline +* @constructor +* @param {Vector3 Array} pts A set of points that define the points the path will pass through (starting with starting control point, and ending with a control point)
+Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value. +* @example +* LTSpline ltSpline = new LTSpline( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(0f,0f,0f), new Vector3(0f,0.5f,0f), new Vector3(1f,1f,0f), new Vector3(1f,1f,0f)} );

+* LeanTween.moveSpline(lt, ltSpline.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
+* Vector3 pt = ltSpline.point( 0.6f ); // retrieve a point along the path +*/ +[System.Serializable] +public class LTSpline { + public static int DISTANCE_COUNT = 3; // increase for a more accurate constant speed + public static int SUBLINE_COUNT = 20; // increase for a more accurate smoothing of the curves into lines + + /** + * @property {float} distance distance of the spline (in unity units) + */ + public float distance = 0f; + + public bool constantSpeed = true; + + public Vector3[] pts; + [System.NonSerialized] + public Vector3[] ptsAdj; + public int ptsAdjLength; + public bool orientToPath; + public bool orientToPath2d; + private int numSections; + private int currPt; + + public LTSpline( Vector3[] pts ){ + init( pts, true); + } + + public LTSpline( Vector3[] pts, bool constantSpeed ) { + this.constantSpeed = constantSpeed; + init(pts, constantSpeed); + } + + private void init( Vector3[] pts, bool constantSpeed){ + if(pts.Length<4){ + LeanTween.logError( "LeanTween - When passing values for a spline path, you must pass four or more values!" ); + return; + } + + this.pts = new Vector3[pts.Length]; + System.Array.Copy(pts, this.pts, pts.Length); + + numSections = pts.Length - 3; + + float minSegment = float.PositiveInfinity; + Vector3 earlierPoint = this.pts[1]; + float totalDistance = 0f; + for(int i=1; i < this.pts.Length-1; i++){ + // float pointDistance = (this.pts[i]-earlierPoint).sqrMagnitude; + float pointDistance = Vector3.Distance(this.pts[i], earlierPoint); + //Debug.Log("pointDist:"+pointDistance); + if(pointDistance < minSegment){ + minSegment = pointDistance; + } + + totalDistance += pointDistance; + } + + if(constantSpeed){ + minSegment = totalDistance / (numSections*SUBLINE_COUNT); + //Debug.Log("minSegment:"+minSegment+" numSections:"+numSections); + + float minPrecision = minSegment / SUBLINE_COUNT; // number of subdivisions in each segment + int precision = (int)Mathf.Ceil(totalDistance / minPrecision) * DISTANCE_COUNT; + // Debug.Log("precision:"+precision); + if(precision<=1) // precision has to be greater than one + precision = 2; + + ptsAdj = new Vector3[ precision ]; + earlierPoint = interp( 0f ); + int num = 1; + ptsAdj[0] = earlierPoint; + distance = 0f; + for(int i = 0; i < precision + 1; i++){ + float fract = ((float)(i)) / precision; + // Debug.Log("fract:"+fract); + Vector3 point = interp( fract ); + float dist = Vector3.Distance(point, earlierPoint); + + // float dist = (point-earlierPoint).sqrMagnitude; + if(dist>=minPrecision || fract>=1.0f){ + ptsAdj[num] = point; + distance += dist; // only add it to the total distance once we know we are adding it as an adjusted point + + earlierPoint = point; + // Debug.Log("fract:"+fract+" point:"+point); + num++; + } + } + // make sure there is a point at the very end + /*num++; + Vector3 endPoint = interp( 1f ); + ptsAdj[num] = endPoint;*/ + // Debug.Log("fract 1f endPoint:"+endPoint); + + ptsAdjLength = num; + } + // Debug.Log("map 1f:"+map(1f)+" end:"+ptsAdj[ ptsAdjLength-1 ]); + + // Debug.Log("ptsAdjLength:"+ptsAdjLength+" minPrecision:"+minPrecision+" precision:"+precision); + } + + public Vector3 map( float u ){ + if(u>=1f) + return pts[ pts.Length - 2]; + float t = u * (ptsAdjLength-1); + int first = (int)Mathf.Floor( t ); + int next = (int)Mathf.Ceil( t ); + + if(first<0) + first = 0; + + Vector3 val = ptsAdj[ first ]; + + + Vector3 nextVal = ptsAdj[ next ]; + float diff = t - first; + + // Debug.Log("u:"+u+" val:"+val +" nextVal:"+nextVal+" diff:"+diff+" first:"+first+" next:"+next); + + val = val + (nextVal - val) * diff; + + return val; + } + + public Vector3 interp(float t) { + currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + + //Debug.Log("currPt:"+currPt+" numSections:"+numSections+" pts.Length :"+pts.Length ); + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + + Vector3 val = (.5f * ( + (-a + 3f * b - 3f * c + d) * (u * u * u) + + (2f * a - 5f * b + 4f * c - d) * (u * u) + + (-a + c) * u + + 2f * b)); + // Debug.Log("currPt:"+currPt+" t:"+t+" val.x"+val.x+" y:"+val.y+" z:"+val.z); + + return val; + } + + /** + * Retrieve a point along a path Move a GameObject to a certain location + * + * @method ratioAtPoint + * @param {Vector3} point:Vector3 given a current location it makes the best approximiation of where it is along the path ratio-wise (0-1) + * @return {float} float of ratio along the path + * @example + * ratioIter = ltSpline.ratioAtPoint( transform.position ); + */ + public float ratioAtPoint( Vector3 pt ){ + float closestDist = float.MaxValue; + int closestI = 0; + for (int i = 0; i < ptsAdjLength; i++) { + float dist = Vector3.Distance(pt, ptsAdj[i]); + // Debug.Log("i:"+i+" dist:"+dist); + if(distMove a GameObject to a certain location + * + * @method point + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @return {Vector3} Vector3 position of the point along the path + * @example + * transform.position = ltSpline.point( 0.6f ); + */ + public Vector3 point( float ratio ){ + float t = ratio>1f?1f:ratio; + return constantSpeed ? map(t) : interp(t); + } + + public void place2d( Transform transform, float ratio ){ + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 v3Dir = point( ratio ) - transform.position; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.eulerAngles = new Vector3(0, 0, angle); + } + } + + public void placeLocal2d( Transform transform, float ratio ){ + Transform trans = transform.parent; + if(trans==null){ // this has no parent, just do a regular transform + place2d(transform, ratio); + return; + } + transform.localPosition = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f){ + Vector3 ptAhead = point( ratio );//trans.TransformPoint( ); + Vector3 v3Dir = ptAhead - transform.localPosition; + float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; + transform.localEulerAngles = new Vector3(0, 0, angle); + } + } -private static float easeInSine(float start, float end, float val){ - end -= start; - return -end * Mathf.Cos(val / 1 * (Mathf.PI / 2)) + end + start; -} -private static float easeOutSine(float start, float end, float val){ - end -= start; - return end * Mathf.Sin(val / 1 * (Mathf.PI / 2)) + start; -} + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) Move a GameObject to a certain location + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.place( transform, 0.6f ); + */ + public void place( Transform transform, float ratio ){ + place(transform, ratio, Vector3.up); + } -private static float easeInOutSine(float start, float end, float val){ - end -= start; - return -end / 2 * (Mathf.Cos(Mathf.PI * val / 1) - 1) + start; -} + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path Move a GameObject to a certain location + * + * @method place + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.place( transform, 0.6f, Vector3.left ); + */ + public void place( Transform transform, float ratio, Vector3 worldUp ){ + // ratio = Mathf.Repeat(ratio, 1.0f); // make sure ratio is always between 0-1 + transform.position = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f) + transform.LookAt( point( ratio ), worldUp ); -private static float easeInExpo(float start, float end, float val){ - end -= start; - return end * Mathf.Pow(2, 10 * (val / 1 - 1)) + start; -} + } -private static float easeOutExpo(float start, float end, float val){ - end -= start; - return end * (-Mathf.Pow(2, -10 * val / 1) + 1) + start; -} + /** + * Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space Move a GameObject to a certain location + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @example + * ltPath.placeLocal( transform, 0.6f ); + */ + public void placeLocal( Transform transform, float ratio ){ + placeLocal( transform, ratio, Vector3.up ); + } -private static float easeInOutExpo(float start, float end, float val){ - val /= .5f; - end -= start; - if (val < 1) return end / 2 * Mathf.Pow(2, 10 * (val - 1)) + start; - val--; - return end / 2 * (-Mathf.Pow(2, -10 * val) + 2) + start; -} + /** + * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space Move a GameObject to a certain location + * + * @method placeLocal + * @param {Transform} transform:Transform the transform of the object you wish to place along the path + * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) + * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up + * @example + * ltPath.placeLocal( transform, 0.6f, Vector3.left ); + */ + public void placeLocal( Transform transform, float ratio, Vector3 worldUp ){ + transform.localPosition = point( ratio ); + ratio += 0.001f; + if(ratio<=1.0f) + transform.LookAt( transform.parent.TransformPoint( point( ratio ) ), worldUp ); + } -private static float easeInCirc(float start, float end, float val){ - end -= start; - return -end * (Mathf.Sqrt(1 - val * val) - 1) + start; -} + public void gizmoDraw(float t = -1.0f) { + if(ptsAdj==null || ptsAdj.Length<=0) + return; -private static float easeOutCirc(float start, float end, float val){ - val--; - end -= start; - return end * Mathf.Sqrt(1 - val * val) + start; -} + Vector3 prevPt = ptsAdj[0]; -private static float easeInOutCirc(float start, float end, float val){ - val /= .5f; - end -= start; - if (val < 1) return -end / 2 * (Mathf.Sqrt(1 - val * val) - 1) + start; - val -= 2; - return end / 2 * (Mathf.Sqrt(1 - val * val) + 1) + start; -} + for (int i = 0; i < ptsAdjLength; i++) { + Vector3 currPt2 = ptsAdj[i]; + // Debug.Log("currPt2:"+currPt2); + //Gizmos.color = new Color(UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),1); + Gizmos.DrawLine(prevPt, currPt2); + prevPt = currPt2; + } + } -private static float easeInBounce(float start, float end, float val){ - end -= start; - float d = 1f; - return end - easeOutBounce(0, end, d-val) + start; -} + public void drawGizmo( Color color ) { + if( this.ptsAdjLength>=4){ -private static float easeOutBounce(float start, float end, float val){ - val /= 1f; - end -= start; - if (val < (1 / 2.75f)){ - return end * (7.5625f * val * val) + start; - }else if (val < (2 / 2.75f)){ - val -= (1.5f / 2.75f); - return end * (7.5625f * (val) * val + .75f) + start; - }else if (val < (2.5 / 2.75)){ - val -= (2.25f / 2.75f); - return end * (7.5625f * (val) * val + .9375f) + start; - }else{ - val -= (2.625f / 2.75f); - return end * (7.5625f * (val) * val + .984375f) + start; - } -} + Vector3 prevPt = this.ptsAdj[0]; -/*private static float easeOutBounce( float start, float end, float val, float overshoot = 1.0f ){ - end -= start; - float baseAmt = 2.75f * overshoot; - float baseAmt2 = baseAmt * baseAmt; - Debug.Log("val:"+val); // 1f, 0.75f, 0.5f, 0.25f, 0.125f - if (val < ((baseAmt-(baseAmt - 1f)) / baseAmt)){ // 0.36 - return end * (baseAmt2 * val * val) + start; // 1 - 1/1 - - }else if (val < ((baseAmt-0.75f) / baseAmt)){ // .72 - val -= ((baseAmt-(baseAmt - 1f - 0.5f)) / baseAmt); // 1.25f - return end * (baseAmt2 * val * val + .75f) + start; // 1 - 1/(4) - - }else if (val < ((baseAmt-(baseAmt - 1f - 0.5f - 0.25f)) / baseAmt)){ // .909 - val -= ((baseAmt-0.5f) / baseAmt); // 0.5 - return end * (baseAmt2 * val * val + .9375f) + start; // 1 - 1/(4*4) - - }else{ // x - // Debug.Log("else val:"+val); - val -= ((baseAmt-0.125f) / baseAmt); // 0.125 - return end * (baseAmt2 * val * val + .984375f) + start; // 1 - 1/(4*4*4) - - } -}*/ - -private static float easeInOutBounce(float start, float end, float val){ - end -= start; - float d= 1f; - if (val < d/2) return easeInBounce(0, end, val*2) * 0.5f + start; - else return easeOutBounce(0, end, val*2-d) * 0.5f + end*0.5f + start; -} + Color colorBefore = Gizmos.color; + Gizmos.color = color; + for (int i = 0; i < this.ptsAdjLength; i++) { + Vector3 currPt2 = this.ptsAdj[i]; + // Debug.Log("currPt2:"+currPt2); -private static float easeInBack(float start, float end, float val, float overshoot = 1.0f){ - end -= start; - val /= 1; - float s= 1.70158f * overshoot; - return end * (val) * val * ((s + 1) * val - s) + start; -} + Gizmos.DrawLine(prevPt, currPt2); + prevPt = currPt2; + } + Gizmos.color = colorBefore; + } + } -private static float easeOutBack(float start, float end, float val, float overshoot = 1.0f){ - float s = 1.70158f * overshoot; - end -= start; - val = (val / 1) - 1; - return end * ((val) * val * ((s + 1) * val + s) + 1) + start; -} + public static void drawGizmo(Transform[] arr, Color color) { + if(arr.Length>=4){ + Vector3[] vec3s = new Vector3[arr.Length]; + for(int i = 0; i < arr.Length; i++){ + vec3s[i] = arr[i].position; + } + LTSpline spline = new LTSpline(vec3s); + Vector3 prevPt = spline.ptsAdj[0]; -private static float easeInOutBack(float start, float end, float val, float overshoot = 1.0f){ - float s = 1.70158f * overshoot; - end -= start; - val /= .5f; - if ((val) < 1){ - s *= (1.525f) * overshoot; - return end / 2 * (val * val * (((s) + 1) * val - s)) + start; - } - val -= 2; - s *= (1.525f) * overshoot; - return end / 2 * ((val) * val * (((s) + 1) * val + s) + 2) + start; -} + Color colorBefore = Gizmos.color; + Gizmos.color = color; + for (int i = 0; i < spline.ptsAdjLength; i++) { + Vector3 currPt2 = spline.ptsAdj[i]; + // Debug.Log("currPt2:"+currPt2); -private static float easeInElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f){ - end -= start; - - float p = period; - float s = 0f; - float a = 0f; - - if (val == 0f) return start; - - if (val == 1f) return start + end; - - if (a == 0f || a < Mathf.Abs(end)){ - a = end; - s = p / 4f; - }else{ - s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); - } - - if(overshoot>1f && val>0.6f ) - overshoot = 1f + ((1f-val) / 0.4f * (overshoot-1f)); - // Debug.Log("ease in elastic val:"+val+" a:"+a+" overshoot:"+overshoot); - - val = val-1f; - return start-(a * Mathf.Pow(2f, 10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p)) * overshoot; -} - -private static float easeOutElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f){ - end -= start; - - float p = period; - float s = 0f; - float a = 0f; - - if (val == 0f) return start; - - // Debug.Log("ease out elastic val:"+val+" a:"+a); - if (val == 1f) return start + end; - - if (a == 0f || a < Mathf.Abs(end)){ - a = end; - s = p / 4f; - }else{ - s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); - } - if(overshoot>1f && val<0.4f ) - overshoot = 1f + (val / 0.4f * (overshoot-1f)); - // Debug.Log("ease out elastic val:"+val+" a:"+a+" overshoot:"+overshoot); - - return start + end + a * Mathf.Pow(2f, -10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p) * overshoot; -} - -private static float easeInOutElastic(float start, float end, float val, float overshoot = 1.0f, float period = 0.3f) -{ - end -= start; - - float p = period; - float s = 0f; - float a = 0f; - - if (val == 0f) return start; - - val = val / (1f/2f); - if (val == 2f) return start + end; - - if (a == 0f || a < Mathf.Abs(end)){ - a = end; - s = p / 4f; - }else{ - s = p / (2f * Mathf.PI) * Mathf.Asin(end / a); - } - - if(overshoot>1f){ - if( val<0.2f ){ - overshoot = 1f + (val / 0.2f * (overshoot-1f)); - }else if( val > 0.8f ){ - overshoot = 1f + ((1f-val) / 0.2f * (overshoot-1f)); - } - } - - if (val < 1f){ - val = val-1f; - return start - 0.5f * (a * Mathf.Pow(2f, 10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p)) * overshoot; - } - val = val-1f; - return end + start + a * Mathf.Pow(2f, -10f * val) * Mathf.Sin((val - s) * (2f * Mathf.PI) / p) * 0.5f * overshoot; -} + Gizmos.DrawLine(prevPt, currPt2); + prevPt = currPt2; + } + Gizmos.color = colorBefore; + } + } -// LeanTween Listening/Dispatch -private static System.Action[] eventListeners; -private static GameObject[] goListeners; -private static int eventsMaxSearch = 0; -public static int EVENTS_MAX = 10; -public static int LISTENERS_MAX = 10; -private static int INIT_LISTENERS_MAX = LISTENERS_MAX; + public static void drawLine(Transform[] arr, float width, Color color) { + if(arr.Length>=4){ -public static void addListener( int eventId, System.Action callback ){ - addListener(tweenEmpty, eventId, callback); -} + } + } -/** -* Add a listener method to be called when the appropriate LeanTween.dispatchEvent is called -* -* @method LeanTween.addListener -* @param {GameObject} caller:GameObject the gameObject the listener is attached to -* @param {int} eventId:int a unique int that describes the event (best to use an enum) -* @param {System.Action} callback:System.Action the method to call when the event has been dispatched -* @example -* LeanTween.addListener(gameObject, (int)MyEvents.JUMP, jumpUp);
-*
-* void jumpUp( LTEvent e ){ Debug.Log("jump!"); }
-*/ -public static void addListener( GameObject caller, int eventId, System.Action callback ){ - if(eventListeners==null){ - INIT_LISTENERS_MAX = LISTENERS_MAX; - eventListeners = new System.Action[ EVENTS_MAX * LISTENERS_MAX ]; - goListeners = new GameObject[ EVENTS_MAX * LISTENERS_MAX ]; - } - // Debug.Log("searching for an empty space for:"+caller + " eventid:"+event); - for(i = 0; i < INIT_LISTENERS_MAX; i++){ - int point = eventId*INIT_LISTENERS_MAX + i; - if(goListeners[ point ]==null || eventListeners[ point ]==null){ - eventListeners[ point ] = callback; - goListeners[ point ] = caller; - if(i>=eventsMaxSearch) - eventsMaxSearch = i+1; - // Debug.Log("adding event for:"+caller.name); - - return; - } - #if UNITY_FLASH - if(goListeners[ point ] == caller && System.Object.ReferenceEquals( eventListeners[ point ], callback)){ - // Debug.Log("This event is already being listened for."); - return; - } - #else - if(goListeners[ point ] == caller && System.Object.Equals( eventListeners[ point ], callback)){ - // Debug.Log("This event is already being listened for."); - return; - } - #endif - } - Debug.LogError("You ran out of areas to add listeners, consider increasing INIT_LISTENERS_MAX, ex: LeanTween.INIT_LISTENERS_MAX = "+(INIT_LISTENERS_MAX*2)); -} + /*public Vector3 Velocity(float t) { + t = map( t ); + + int numSections = pts.Length - 3; + int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + + return 1.5f * (-a + 3f * b - 3f * c + d) * (u * u) + + (2f * a -5f * b + 4f * c - d) * u + + .5f * c - .5f * a; + }*/ + + public void drawLinesGLLines(Material outlineMaterial, Color color, float width){ + GL.PushMatrix(); + outlineMaterial.SetPass(0); + GL.LoadPixelMatrix(); + GL.Begin(GL.LINES); + GL.Color(color); + + if (constantSpeed) { + if (this.ptsAdjLength >= 4) { + + Vector3 prevPt = this.ptsAdj[0]; + + for (int i = 0; i < this.ptsAdjLength; i++) { + Vector3 currPt2 = this.ptsAdj[i]; + GL.Vertex(prevPt); + GL.Vertex(currPt2); + + prevPt = currPt2; + } + } -public static bool removeListener( int eventId, System.Action callback ){ - return removeListener( tweenEmpty, eventId, callback); -} + } else { + if (this.pts.Length >= 4) { -/** -* Remove an event listener you have added -* @method LeanTween.removeListener -* @param {GameObject} caller:GameObject the gameObject the listener is attached to -* @param {int} eventId:int a unique int that describes the event (best to use an enum) -* @param {System.Action} callback:System.Action the method that was specified to call when the event has been dispatched -* @example -* LeanTween.removeListener(gameObject, (int)MyEvents.JUMP, jumpUp);
-*
-* void jumpUp( LTEvent e ){ }
-*/ -public static bool removeListener( GameObject caller, int eventId, System.Action callback ){ - for(i = 0; i < eventsMaxSearch; i++){ - int point = eventId*INIT_LISTENERS_MAX + i; - #if UNITY_FLASH - if(goListeners[ point ] == caller && System.Object.ReferenceEquals( eventListeners[ point ], callback) ){ - #else - if(goListeners[ point ] == caller && System.Object.Equals( eventListeners[ point ], callback) ){ - #endif - eventListeners[ point ] = null; - goListeners[ point ] = null; - return true; - } - } - return false; -} + Vector3 prevPt = this.pts[0]; -/** -* Tell the added listeners that you are dispatching the event -* @method LeanTween.dispatchEvent -* @param {int} eventId:int a unique int that describes the event (best to use an enum) -* @example -* LeanTween.dispatchEvent( (int)MyEvents.JUMP );
-*/ -public static void dispatchEvent( int eventId ){ - dispatchEvent( eventId, null); -} + float split = 1f / ((float)this.pts.Length * 10f); -/** -* Tell the added listeners that you are dispatching the event -* @method LeanTween.dispatchEvent -* @param {int} eventId:int a unique int that describes the event (best to use an enum) -* @param {object} data:object Pass data to the listener, access it from the listener with *.data on the LTEvent object -* @example -* LeanTween.dispatchEvent( (int)MyEvents.JUMP, transform );
-*
-* void jumpUp( LTEvent e ){
-*   Transform tran = (Transform)e.data;
-* }
-*/ -public static void dispatchEvent( int eventId, object data ){ - for(int k = 0; k < eventsMaxSearch; k++){ - int point = eventId*INIT_LISTENERS_MAX + k; - if(eventListeners[ point ]!=null){ - if(goListeners[point]){ - eventListeners[ point ]( new LTEvent(eventId, data) ); - }else{ - eventListeners[ point ] = null; - } - } - } -} + float iter = 0f; + while (iter < 1f) { + float at = iter / 1f; + Vector3 currPt2 = interp(at); + // Debug.Log("currPt2:"+currPt2); -} // End LeanTween class + GL.Vertex(prevPt); + GL.Vertex(currPt2); -public class LTBezier { - public float length; - - private Vector3 a; - private Vector3 aa; - private Vector3 bb; - private Vector3 cc; - private float len; - private float[] arcLengths; - - public LTBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float precision){ - this.a = a; - aa = (-a + 3*(b-c) + d); - bb = 3*(a+c) - 6*b; - cc = 3*(b-a); - - this.len = 1.0f / precision; - arcLengths = new float[(int)this.len + (int)1]; - arcLengths[0] = 0; - - Vector3 ov = a; - Vector3 v; - float clen = 0.0f; - for(int i = 1; i <= this.len; i++) { - v = bezierPoint(i * precision); - clen += (ov - v).magnitude; - this.arcLengths[i] = clen; - ov = v; - } - this.length = clen; - } + prevPt = currPt2; - private float map(float u) { - float targetLength = u * this.arcLengths[(int)this.len]; - int low = 0; - int high = (int)this.len; - int index = 0; - while (low < high) { - index = low + ((int)((high - low) / 2.0f) | 0); - if (this.arcLengths[index] < targetLength) { - low = index + 1; - } else { - high = index; + iter += split; + } } } - if(this.arcLengths[index] > targetLength) - index--; - if(index<0) - index = 0; - return (index + (targetLength - arcLengths[index]) / (arcLengths[index + 1] - arcLengths[index])) / this.len; - } - private Vector3 bezierPoint(float t){ - return ((aa* t + (bb))* t + cc)* t + a; - } + GL.End(); + GL.PopMatrix(); - public Vector3 point(float t){ - return bezierPoint( map(t) ); } -} -/** -* Manually animate along a bezier path with this class -* @class LTBezierPath -* @constructor -* @param {Vector3 Array} pts A set of points that define one or many bezier paths (the paths should be passed in multiples of 4, which correspond to each individual bezier curve) -* @example -* LTBezierPath ltPath = new LTBezierPath( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(1f,0f,0f), new Vector3(1f,0f,0f), new Vector3(1f,1f,0f)} );

-* LeanTween.move(lt, ltPath.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
-* Vector3 pt = ltPath.point( 0.6f ); // retrieve a point along the path -*/ -public class LTBezierPath { - public Vector3[] pts; - public float length; - public bool orientToPath; - public bool orientToPath2d; - - private LTBezier[] beziers; - private float[] lengthRatio; - private int currentBezier=0,previousBezier=0; - - public LTBezierPath(){ } - public LTBezierPath( Vector3[] pts_ ){ - setPoints( pts_ ); - } - - public void setPoints( Vector3[] pts_ ){ - if(pts_.Length<4) - LeanTween.logError( "LeanTween - When passing values for a vector path, you must pass four or more values!" ); - if(pts_.Length%4!=0) - LeanTween.logError( "LeanTween - When passing values for a vector path, they must be in sets of four: controlPoint1, controlPoint2, endPoint2, controlPoint2, controlPoint2..." ); - - pts = pts_; - - int k = 0; - beziers = new LTBezier[ pts.Length / 4 ]; - lengthRatio = new float[ beziers.Length ]; - int i; - length = 0; - for(i = 0; i < pts.Length; i+=4){ - beziers[k] = new LTBezier(pts[i+0],pts[i+2],pts[i+1],pts[i+3],0.05f); - length += beziers[k].length; - k++; - } - // Debug.Log("beziers.Length:"+beziers.Length + " beziers:"+beziers); - for(i = 0; i < beziers.Length; i++){ - lengthRatio[i] = beziers[i].length / length; - } - } - - /** - * Retrieve a point along a path - * - * @method point - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @return {Vector3} Vector3 position of the point along the path - * @example - * transform.position = ltPath.point( 0.6f ); - */ - public Vector3 point( float ratio ){ - float added = 0.0f; - for(int i = 0; i < lengthRatio.Length; i++){ - added += lengthRatio[i]; - if(added >= ratio) - return beziers[i].point( (ratio-(added-lengthRatio[i])) / lengthRatio[i] ); - } - return beziers[lengthRatio.Length-1].point( 1.0f ); - } - - public void place2d( Transform transform, float ratio ){ - transform.position = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f){ - Vector3 v3Dir = point( ratio ) - transform.position; - float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; - transform.eulerAngles = new Vector3(0, 0, angle); - } - } - - public void placeLocal2d( Transform transform, float ratio ){ - transform.localPosition = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f){ - Vector3 v3Dir = transform.parent.TransformPoint( point( ratio ) ) - transform.localPosition; - float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; - transform.eulerAngles = new Vector3(0, 0, angle); - } - } - - /** - * Place an object along a certain point on the path (facing the direction perpendicular to the path) - * - * @method place - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @example - * ltPath.place( transform, 0.6f ); - */ - public void place( Transform transform, float ratio ){ - place( transform, ratio, Vector3.up ); - - } - - /** - * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - * - * @method place - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up - * @example - * ltPath.place( transform, 0.6f, Vector3.left ); - */ - public void place( Transform transform, float ratio, Vector3 worldUp ){ - transform.position = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f) - transform.LookAt( point( ratio ), worldUp ); - - } - - /** - * Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space - * - * @method placeLocal - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @example - * ltPath.placeLocal( transform, 0.6f ); - */ - public void placeLocal( Transform transform, float ratio ){ - placeLocal( transform, ratio, Vector3.up ); - } - - /** - * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space - * - * @method placeLocal - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up - * @example - * ltPath.placeLocal( transform, 0.6f, Vector3.left ); - */ - public void placeLocal( Transform transform, float ratio, Vector3 worldUp ){ - transform.localPosition = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f) - transform.LookAt( transform.parent.TransformPoint( point( ratio ) ), worldUp ); - } - - public void gizmoDraw(float t = -1.0f) - { - Vector3 prevPt = point(0); + public Vector3[] generateVectors(){ + if (this.pts.Length >= 4) { + List meshPoints = new List(); + Vector3 prevPt = this.pts[0]; + meshPoints.Add(prevPt); - for (int i = 1; i <= 120; i++) - { - float pm = (float)i / 120f; - Vector3 currPt2 = point(pm); - //Gizmos.color = new Color(UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),1); - Gizmos.color = (previousBezier == currentBezier) ? Color.magenta : Color.grey; - Gizmos.DrawLine(currPt2, prevPt); - prevPt = currPt2; - previousBezier = currentBezier; + float split = 1f / ((float)this.pts.Length * 10f); + + float iter = 0f; + while (iter < 1f) { + float at = iter / 1f; + Vector3 currPt2 = interp(at); + // Debug.Log("currPt2:"+currPt2); + + // GL.Vertex(prevPt); + // GL.Vertex(currPt2); + meshPoints.Add(currPt2); + + // prevPt = currPt2; + + iter += split; + } + + meshPoints.ToArray(); } + return null; } } /** -* Animate along a set of points that need to be in the format: controlPoint, point1, point2.... pointLast, endControlPoint -* @class LTSpline -* @constructor -* @param {Vector3 Array} pts A set of points that define the points the path will pass through (starting with starting control point, and ending with a control point) -* @example -* LTSpline ltSpline = new LTSpline( new Vector3[] { new Vector3(0f,0f,0f),new Vector3(0f,0f,0f), new Vector3(0f,0.5f,0f), new Vector3(1f,1f,0f), new Vector3(1f,1f,0f)} );

-* LeanTween.moveSpline(lt, ltSpline.vec3, 4.0f).setOrientToPath(true).setDelay(1f).setEase(LeanTweenType.easeInOutQuad); // animate
-* Vector3 pt = ltSpline.point( 0.6f ); // retrieve a point along the path -*/ -[System.Serializable] -public class LTSpline { - public static int DISTANCE_COUNT = 30; // increase for a more accurate constant speed - public static int SUBLINE_COUNT = 50; // increase for a more accurate smoothing of the curves into lines - - public Vector3[] pts; - public Vector3[] ptsAdj; - public int ptsAdjLength; - public bool orientToPath; - public bool orientToPath2d; - private int numSections; - private int currPt; - private float totalLength; - - public LTSpline(params Vector3[] pts) { - this.pts = new Vector3[pts.Length]; - System.Array.Copy(pts, this.pts, pts.Length); - - numSections = pts.Length - 3; - - float minSegment = float.PositiveInfinity; - Vector3 earlierPoint = this.pts[1]; - float totalDistance = 0f; - for(int i=2; i < this.pts.Length-2; i++){ - float pointDistance = Vector3.Distance(this.pts[i], earlierPoint); - if(pointDistance < minSegment){ - minSegment = pointDistance; - } - - totalDistance += pointDistance; - } - - float minPrecision = minSegment / SUBLINE_COUNT; // number of subdivisions in each segment - int precision = (int)Mathf.Ceil(totalDistance / minPrecision) * DISTANCE_COUNT; - - ptsAdj = new Vector3[ precision ]; - earlierPoint = interp( 0f ); - int num = 0; - for(int i = 0; i < precision; i++){ - float fract = ((float)(i+1f)) / precision; - Vector3 point = interp( fract ); - float dist = Vector3.Distance(point, earlierPoint); - if(dist>=minPrecision){ - ptsAdj[num] = point; - - earlierPoint = point; - // Debug.Log("fract:"+fract+" point:"+point); - num++; - } - } - // make sure there is a point at the very end - /*num++; - Vector3 endPoint = interp( 1f ); - ptsAdj[num] = endPoint;*/ - // Debug.Log("fract 1f endPoint:"+endPoint); - - ptsAdjLength = num; - // Debug.Log("map 1f:"+map(1f)+" end:"+ptsAdj[ ptsAdjLength-1 ]); - - // Debug.Log("ptsAdjLength:"+ptsAdjLength+" minPrecision:"+minPrecision+" precision:"+precision); - - } - - public Vector3 map( float u ){ - if(u>=1f) - return pts[ pts.Length - 2]; - float t = u * (ptsAdjLength-1); - int first = (int)Mathf.Floor( t ); - int next = (int)Mathf.Ceil( t ); - - Vector3 val = ptsAdj[ first ]; - - - Vector3 nextVal = ptsAdj[ next ]; - float diff = t - first; - - // Debug.Log("u:"+u+" val:"+val +" nextVal:"+nextVal+" diff:"+diff+" first:"+first+" next:"+next); - - val = val + (nextVal - val) * diff; - - return val; - } - - public Vector3 interp(float t) { - currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); - float u = t * (float) numSections - (float) currPt; - - // Debug.Log("currPt:"+currPt+" numSections:"+numSections+" pts.Length :"+pts.Length ); - Vector3 a = pts[currPt]; - Vector3 b = pts[currPt + 1]; - Vector3 c = pts[currPt + 2]; - Vector3 d = pts[currPt + 3]; - - return .5f * ( - (-a + 3f * b - 3f * c + d) * (u * u * u) - + (2f * a - 5f * b + 4f * c - d) * (u * u) - + (-a + c) * u - + 2f * b - ); - } - - /** - * Retrieve a point along a path - * - * @method point - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @return {Vector3} Vector3 position of the point along the path - * @example - * transform.position = ltSpline.point( 0.6f ); - */ - public Vector3 point( float ratio ){ - float t = ratio>1f?1f:ratio; - - return map(t); - } - - public void place2d( Transform transform, float ratio ){ - transform.position = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f){ - Vector3 v3Dir = point( ratio ) - transform.position; - float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; - transform.eulerAngles = new Vector3(0, 0, angle); - } - } - - public void placeLocal2d( Transform transform, float ratio ){ - transform.localPosition = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f){ - Vector3 v3Dir = transform.parent.TransformPoint( point( ratio ) ) - transform.localPosition; - float angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg; - transform.eulerAngles = new Vector3(0, 0, angle); - } - } - - - /** - * Place an object along a certain point on the path (facing the direction perpendicular to the path) - * - * @method place - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @example - * ltPath.place( transform, 0.6f ); - */ - public void place( Transform transform, float ratio ){ - place(transform, ratio, Vector3.up); - } - - /** - * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - * - * @method place - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up - * @example - * ltPath.place( transform, 0.6f, Vector3.left ); - */ - public void place( Transform transform, float ratio, Vector3 worldUp ){ - transform.position = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f) - transform.LookAt( point( ratio ), worldUp ); - - } - - /** - * Place an object along a certain point on the path (facing the direction perpendicular to the path) - Local Space, not world-space - * - * @method placeLocal - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @example - * ltPath.placeLocal( transform, 0.6f ); - */ - public void placeLocal( Transform transform, float ratio ){ - placeLocal( transform, ratio, Vector3.up ); - } - - /** - * Place an object along a certain point on the path, with it facing a certain direction perpendicular to the path - Local Space, not world-space - * - * @method placeLocal - * @param {Transform} transform:Transform the transform of the object you wish to place along the path - * @param {float} ratio:float ratio of the point along the path you wish to receive (0-1) - * @param {Vector3} rotation:Vector3 the direction in which to place the transform ex: Vector3.up - * @example - * ltPath.placeLocal( transform, 0.6f, Vector3.left ); - */ - public void placeLocal( Transform transform, float ratio, Vector3 worldUp ){ - transform.localPosition = point( ratio ); - ratio += 0.001f; - if(ratio<=1.0f) - transform.LookAt( transform.parent.TransformPoint( point( ratio ) ), worldUp ); - } - - public void gizmoDraw(float t = -1.0f) { - - Vector3 prevPt = point(0); - - for (int i = 1; i <= 120; i++) { - float pm = (float) i / 120f; - Vector3 currPt2 = point(pm); - //Gizmos.color = new Color(UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),UnityEngine.Random.Range(0f,1f),1); - Gizmos.DrawLine(currPt2, prevPt); - prevPt = currPt2; - } - - } - - /*public Vector3 Velocity(float t) { - t = map( t ); - - int numSections = pts.Length - 3; - int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); - float u = t * (float) numSections - (float) currPt; - - Vector3 a = pts[currPt]; - Vector3 b = pts[currPt + 1]; - Vector3 c = pts[currPt + 2]; - Vector3 d = pts[currPt + 3]; - - return 1.5f * (-a + 3f * b - 3f * c + d) * (u * u) - + (2f * a -5f * b + 4f * c - d) * u - + .5f * c - .5f * a; - }*/ -} - -/** -* Animate GUI Elements by creating this object and passing the *.rect variable to the GUI method

-* Example Javascript:
var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
-* LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 );
-* function OnGUI(){
-*   if(GUI.Button(bRect.rect, "Scale")){ }
-* }
-*
-* Example C#:
-* LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
-* LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f );
-* void OnGUI(){
-*   if(GUI.Button(bRect.rect, "Scale")){ }
-* }
+* Animate GUI Elements by creating this object and passing the *.rect variable to the GUI method

+* Example Javascript:
var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
+* LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 );
+* function OnGUI(){
+*   if(GUI.Button(bRect.rect, "Scale")){ }
+* }
+*
+* Example C#:
+* LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
+* LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f );
+* void OnGUI(){
+*   if(GUI.Button(bRect.rect, "Scale")){ }
+* }
* * @class LTRect * @constructor @@ -4977,146 +3236,146 @@ public class LTSpline { [System.Serializable] public class LTRect : System.Object{ - /** - * Pass this value to the GUI Methods - * - * @property rect - * @type {Rect} rect:Rect Rect object that controls the positioning and size - */ - public Rect _rect; - public float alpha = 1f; - public float rotation; - public Vector2 pivot; - public Vector2 margin; - public Rect relativeRect = new Rect(0f,0f,float.PositiveInfinity,float.PositiveInfinity); - - public bool rotateEnabled; - [HideInInspector] - public bool rotateFinished; - public bool alphaEnabled; - public string labelStr; - public LTGUI.Element_Type type; - public GUIStyle style; - public bool useColor = false; - public Color color = Color.white; - public bool fontScaleToFit; - public bool useSimpleScale; - public bool sizeByHeight; - - public Texture texture; - - private int _id = -1; - [HideInInspector] - public int counter; - - public static bool colorTouched; - - public LTRect(){ - reset(); - this.rotateEnabled = this.alphaEnabled = true; - _rect = new Rect(0f,0f,1f,1f); - } - - public LTRect(Rect rect){ - _rect = rect; - reset(); - } - - public LTRect(float x, float y, float width, float height){ - _rect = new Rect(x,y,width,height); - this.alpha = 1.0f; - this.rotation = 0.0f; - this.rotateEnabled = this.alphaEnabled = false; - } - - public LTRect(float x, float y, float width, float height, float alpha){ - _rect = new Rect(x,y,width,height); - this.alpha = alpha; - this.rotation = 0.0f; - this.rotateEnabled = this.alphaEnabled = false; - } - - public LTRect(float x, float y, float width, float height, float alpha, float rotation){ - _rect = new Rect(x,y,width,height); - this.alpha = alpha; - this.rotation = rotation; - this.rotateEnabled = this.alphaEnabled = false; - if(rotation!=0.0f){ - this.rotateEnabled = true; - resetForRotation(); - } - } - - public bool hasInitiliazed{ - get{ - return _id!=-1; - } - } - - public int id{ - get{ - int toId = _id | counter << 16; - - /*uint backId = toId & 0xFFFF; - uint backCounter = toId >> 16; - if(_id!=backId || backCounter!=counter){ - Debug.LogError("BAD CONVERSION toId:"+_id); - }*/ - - return toId; - } - } - - public void setId( int id, int counter){ - this._id = id; - this.counter = counter; - } - - public void reset(){ - this.alpha = 1.0f; - this.rotation = 0.0f; - this.rotateEnabled = this.alphaEnabled = false; - this.margin = Vector2.zero; - this.sizeByHeight = false; - this.useColor = false; - } - - public void resetForRotation(){ - Vector3 scale = new Vector3(GUI.matrix[0,0], GUI.matrix[1,1], GUI.matrix[2,2]); + /** + * Pass this value to the GUI Methods + * + * @property rect + * @type {Rect} rect:Rect Rect object that controls the positioning and size + */ + public Rect _rect; + public float alpha = 1f; + public float rotation; + public Vector2 pivot; + public Vector2 margin; + public Rect relativeRect = new Rect(0f,0f,float.PositiveInfinity,float.PositiveInfinity); + + public bool rotateEnabled; + [HideInInspector] + public bool rotateFinished; + public bool alphaEnabled; + public string labelStr; + public LTGUI.Element_Type type; + public GUIStyle style; + public bool useColor = false; + public Color color = Color.white; + public bool fontScaleToFit; + public bool useSimpleScale; + public bool sizeByHeight; + + public Texture texture; + + private int _id = -1; + [HideInInspector] + public int counter; + + public static bool colorTouched; + + public LTRect(){ + reset(); + this.rotateEnabled = this.alphaEnabled = true; + _rect = new Rect(0f,0f,1f,1f); + } + + public LTRect(Rect rect){ + _rect = rect; + reset(); + } + + public LTRect(float x, float y, float width, float height){ + _rect = new Rect(x,y,width,height); + this.alpha = 1.0f; + this.rotation = 0.0f; + this.rotateEnabled = this.alphaEnabled = false; + } + + public LTRect(float x, float y, float width, float height, float alpha){ + _rect = new Rect(x,y,width,height); + this.alpha = alpha; + this.rotation = 0.0f; + this.rotateEnabled = this.alphaEnabled = false; + } + + public LTRect(float x, float y, float width, float height, float alpha, float rotation){ + _rect = new Rect(x,y,width,height); + this.alpha = alpha; + this.rotation = rotation; + this.rotateEnabled = this.alphaEnabled = false; + if(rotation!=0.0f){ + this.rotateEnabled = true; + resetForRotation(); + } + } + + public bool hasInitiliazed{ + get{ + return _id!=-1; + } + } + + public int id{ + get{ + int toId = _id | counter << 16; + + /*uint backId = toId & 0xFFFF; + uint backCounter = toId >> 16; + if(_id!=backId || backCounter!=counter){ + Debug.LogError("BAD CONVERSION toId:"+_id); + }*/ + + return toId; + } + } + + public void setId( int id, int counter){ + this._id = id; + this.counter = counter; + } + + public void reset(){ + this.alpha = 1.0f; + this.rotation = 0.0f; + this.rotateEnabled = this.alphaEnabled = false; + this.margin = Vector2.zero; + this.sizeByHeight = false; + this.useColor = false; + } + + public void resetForRotation(){ + Vector3 scale = new Vector3(GUI.matrix[0,0], GUI.matrix[1,1], GUI.matrix[2,2]); if(pivot==Vector2.zero){ pivot = new Vector2((_rect.x+((_rect.width)*0.5f )) * scale.x + GUI.matrix[0,3], (_rect.y+((_rect.height)*0.5f )) * scale.y + GUI.matrix[1,3]); } - } - - public float x{ - get{ return _rect.x; } - set{ _rect.x = value; } - } - - public float y{ - get{ return _rect.y; } - set{ _rect.y = value; } - } - - public float width{ - get{ return _rect.width; } - set{ _rect.width = value; } - } - - public float height{ - get{ return _rect.height; } - set{ _rect.height = value; } - } - - public Rect rect{ - - get{ - if(colorTouched){ - colorTouched = false; - GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,1.0f); - } - if(rotateEnabled){ - if(rotateFinished){ + } + + public float x{ + get{ return _rect.x; } + set{ _rect.x = value; } + } + + public float y{ + get{ return _rect.y; } + set{ _rect.y = value; } + } + + public float width{ + get{ return _rect.width; } + set{ _rect.width = value; } + } + + public float height{ + get{ return _rect.height; } + set{ _rect.height = value; } + } + + public Rect rect{ + + get{ + if(colorTouched){ + colorTouched = false; + GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,1.0f); + } + if(rotateEnabled){ + if(rotateFinished){ rotateFinished = false; rotateEnabled = false; //this.rotation = 0.0f; @@ -5124,72 +3383,72 @@ public class LTRect : System.Object{ }else{ GUIUtility.RotateAroundPivot(rotation, pivot); } - } - if(alphaEnabled){ - GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,alpha); - colorTouched = true; - } - if(fontScaleToFit){ - if(this.useSimpleScale){ - style.fontSize = (int)(_rect.height*this.relativeRect.height); - }else{ - style.fontSize = (int)_rect.height; - } - } - return _rect; - } - - set{ - _rect = value; - } - } - - public LTRect setStyle( GUIStyle style ){ - this.style = style; - return this; - } - - public LTRect setFontScaleToFit( bool fontScaleToFit ){ - this.fontScaleToFit = fontScaleToFit; - return this; - } - - public LTRect setColor( Color color ){ - this.color = color; - this.useColor = true; - return this; - } - - public LTRect setAlpha( float alpha ){ - this.alpha = alpha; - return this; - } - - public LTRect setLabel( String str ){ - this.labelStr = str; - return this; - } - - public LTRect setUseSimpleScale( bool useSimpleScale, Rect relativeRect){ - this.useSimpleScale = useSimpleScale; - this.relativeRect = relativeRect; - return this; - } - - public LTRect setUseSimpleScale( bool useSimpleScale){ - this.useSimpleScale = useSimpleScale; - this.relativeRect = new Rect(0f,0f,Screen.width,Screen.height); - return this; - } - - public LTRect setSizeByHeight( bool sizeByHeight){ - this.sizeByHeight = sizeByHeight; - return this; - } - - public override string ToString(){ - return "x:"+_rect.x+" y:"+_rect.y+" width:"+_rect.width+" height:"+_rect.height; - } + } + if(alphaEnabled){ + GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,alpha); + colorTouched = true; + } + if(fontScaleToFit){ + if(this.useSimpleScale){ + style.fontSize = (int)(_rect.height*this.relativeRect.height); + }else{ + style.fontSize = (int)_rect.height; + } + } + return _rect; + } + + set{ + _rect = value; + } + } + + public LTRect setStyle( GUIStyle style ){ + this.style = style; + return this; + } + + public LTRect setFontScaleToFit( bool fontScaleToFit ){ + this.fontScaleToFit = fontScaleToFit; + return this; + } + + public LTRect setColor( Color color ){ + this.color = color; + this.useColor = true; + return this; + } + + public LTRect setAlpha( float alpha ){ + this.alpha = alpha; + return this; + } + + public LTRect setLabel( String str ){ + this.labelStr = str; + return this; + } + + public LTRect setUseSimpleScale( bool useSimpleScale, Rect relativeRect){ + this.useSimpleScale = useSimpleScale; + this.relativeRect = relativeRect; + return this; + } + + public LTRect setUseSimpleScale( bool useSimpleScale){ + this.useSimpleScale = useSimpleScale; + this.relativeRect = new Rect(0f,0f,Screen.width,Screen.height); + return this; + } + + public LTRect setSizeByHeight( bool sizeByHeight){ + this.sizeByHeight = sizeByHeight; + return this; + } + + public override string ToString(){ + return "x:"+_rect.x+" y:"+_rect.y+" width:"+_rect.width+" height:"+_rect.height; + } } /** @@ -5199,249 +3458,252 @@ public class LTRect : System.Object{ * @param {object} data:object Data that has been passed from the dispatchEvent method */ public class LTEvent { - public int id; - public object data; + public int id; + public object data; - public LTEvent(int id, object data){ - this.id = id; - this.data = data; - } + public LTEvent(int id, object data){ + this.id = id; + this.data = data; + } } public class LTGUI { - public static int RECT_LEVELS = 5; - public static int RECTS_PER_LEVEL = 10; - public static int BUTTONS_MAX = 24; - - private static LTRect[] levels; - private static int[] levelDepths; - private static Rect[] buttons; - private static int[] buttonLevels; - private static int[] buttonLastFrame; - private static LTRect r; - private static Color color = Color.white; - private static bool isGUIEnabled = false; - private static int global_counter = 0; - - public enum Element_Type{ - Texture, - Label - } - - public static void init(){ - if(levels==null){ - levels = new LTRect[RECT_LEVELS*RECTS_PER_LEVEL]; - levelDepths = new int[RECT_LEVELS]; - } - } - - public static void initRectCheck(){ - if(buttons==null){ - buttons = new Rect[BUTTONS_MAX]; - buttonLevels = new int[BUTTONS_MAX]; - buttonLastFrame = new int[BUTTONS_MAX]; - for(int i = 0; i < buttonLevels.Length; i++){ - buttonLevels[i] = -1; - } - } - } - - public static void reset(){ - if(isGUIEnabled){ - isGUIEnabled = false; - for(int i = 0; i < levels.Length; i++){ - levels[i] = null; - } - - for(int i = 0; i < levelDepths.Length; i++){ - levelDepths[i] = 0; - } - } - } - - public static void update( int updateLevel ){ - if(isGUIEnabled){ - init(); - if(levelDepths[updateLevel]>0){ - color = GUI.color; - int baseI = updateLevel*RECTS_PER_LEVEL; - int maxLoop = baseI + levelDepths[updateLevel];// RECTS_PER_LEVEL;//; - - for(int i = baseI; i < maxLoop; i++){ - r = levels[i]; - // Debug.Log("r:"+r+" i:"+i); - if(r!=null /*&& checkOnScreen(r.rect)*/){ - //Debug.Log("label:"+r.labelStr+" textColor:"+r.style.normal.textColor); - if(r.useColor) - GUI.color = r.color; - if(r.type == Element_Type.Label){ - if(r.style!=null) - GUI.skin.label = r.style; - if(r.useSimpleScale){ - GUI.Label( new Rect((r.rect.x + r.margin.x + r.relativeRect.x)*r.relativeRect.width, (r.rect.y + r.margin.y + r.relativeRect.y)*r.relativeRect.height, r.rect.width*r.relativeRect.width, r.rect.height*r.relativeRect.height), r.labelStr ); - }else{ - GUI.Label( new Rect(r.rect.x + r.margin.x, r.rect.y + r.margin.y, r.rect.width, r.rect.height), r.labelStr ); - } - }else if(r.type == Element_Type.Texture && r.texture!=null){ - Vector2 size = r.useSimpleScale ? new Vector2(0f, r.rect.height*r.relativeRect.height) : new Vector2(r.rect.width, r.rect.height); - if(r.sizeByHeight){ - size.x = (float)r.texture.width/(float)r.texture.height * size.y; - } - if(r.useSimpleScale){ - GUI.DrawTexture( new Rect((r.rect.x + r.margin.x + r.relativeRect.x)*r.relativeRect.width, (r.rect.y + r.margin.y + r.relativeRect.y)*r.relativeRect.height, size.x, size.y), r.texture ); - }else{ - GUI.DrawTexture( new Rect(r.rect.x + r.margin.x, r.rect.y + r.margin.y, size.x, size.y), r.texture ); - } - } - } - } - GUI.color = color; - } - } - } - - public static bool checkOnScreen(Rect rect){ - bool offLeft = rect.x + rect.width < 0f; - bool offRight = rect.x > Screen.width; - bool offBottom = rect.y > Screen.height; - bool offTop = rect.y + rect.height < 0f; - - return !(offLeft || offRight || offBottom || offTop); - } - - public static void destroy( int id ){ - int backId = id & 0xFFFF; - int backCounter = id >> 16; - if(id>=0 && levels[backId]!=null && levels[backId].hasInitiliazed && levels[backId].counter==backCounter) - levels[backId] = null; - } - - public static void destroyAll( int depth ){ // clears all gui elements on depth - int maxLoop = depth*RECTS_PER_LEVEL + RECTS_PER_LEVEL; - for(int i = depth*RECTS_PER_LEVEL; levels!=null && i < maxLoop; i++){ - levels[i] = null; - } - } - - public static LTRect label( Rect rect, string label, int depth){ - return LTGUI.label(new LTRect(rect), label, depth); - } - - public static LTRect label( LTRect rect, string label, int depth){ - rect.type = Element_Type.Label; - rect.labelStr = label; - return element(rect, depth); - } - - public static LTRect texture( Rect rect, Texture texture, int depth){ - return LTGUI.texture( new LTRect(rect), texture, depth); - } - - public static LTRect texture( LTRect rect, Texture texture, int depth){ - rect.type = Element_Type.Texture; - rect.texture = texture; - return element(rect, depth); - } - - public static LTRect element( LTRect rect, int depth){ - isGUIEnabled = true; - init(); - int maxLoop = depth*RECTS_PER_LEVEL + RECTS_PER_LEVEL; - int k = 0; - if(rect!=null){ - destroy(rect.id); - } - if(rect.type==LTGUI.Element_Type.Label && rect.style!=null){ - if(rect.style.normal.textColor.a<=0f){ - Debug.LogWarning("Your GUI normal color has an alpha of zero, and will not be rendered."); - } - } - if(rect.relativeRect.width==float.PositiveInfinity){ - rect.relativeRect = new Rect(0f,0f,Screen.width,Screen.height); - } - for(int i = depth*RECTS_PER_LEVEL; i < maxLoop; i++){ - r = levels[i]; - if(r==null){ - r = rect; - r.rotateEnabled = true; - r.alphaEnabled = true; - r.setId( i, global_counter ); - levels[i] = r; - // Debug.Log("k:"+k+ " maxDepth:"+levelDepths[depth]); - if(k>=levelDepths[depth]){ - levelDepths[depth] = k + 1; - } - global_counter++; - return r; - } - k++; - } - - Debug.LogError("You ran out of GUI Element spaces"); - - return null; - } - - public static bool hasNoOverlap( Rect rect, int depth ){ - initRectCheck(); - bool hasNoOverlap = true; - bool wasAddedToList = false; - for(int i = 0; i < buttonLevels.Length; i++){ - // Debug.Log("buttonLastFrame["+i+"]:"+buttonLastFrame[i]); - //Debug.Log("buttonLevels["+i+"]:"+buttonLevels[i]); - if(buttonLevels[i]>=0){ - //Debug.Log("buttonLastFrame["+i+"]:"+buttonLastFrame[i]+" Time.frameCount:"+Time.frameCount); - if( buttonLastFrame[i] + 1 < Time.frameCount ){ // It has to have been visible within the current, or - buttonLevels[i] = -1; - // Debug.Log("resetting i:"+i); - }else{ - //if(buttonLevels[i]>=0) - // Debug.Log("buttonLevels["+i+"]:"+buttonLevels[i]); - if(buttonLevels[i]>depth){ - /*if(firstTouch().x > 0){ - Debug.Log("buttons["+i+"]:"+buttons[i] + " firstTouch:"); - Debug.Log(firstTouch()); - Debug.Log(buttonLevels[i]); - }*/ - if(pressedWithinRect( buttons[i] )){ - hasNoOverlap = false; // there is an overlapping button that is higher - } - } - } - } - - if(wasAddedToList==false && buttonLevels[i]<0){ - wasAddedToList = true; - buttonLevels[i] = depth; - buttons[i] = rect; - buttonLastFrame[i] = Time.frameCount; - } - } - - return hasNoOverlap; - } - - public static bool pressedWithinRect( Rect rect ){ - Vector2 vec2 = firstTouch(); - if(vec2.x<0f) - return false; - float vecY = Screen.height-vec2.y; - return (vec2.x > rect.x && vec2.x < rect.x + rect.width && vecY > rect.y && vecY < rect.y + rect.height); - } - - public static bool checkWithinRect(Vector2 vec2, Rect rect){ - vec2.y = Screen.height-vec2.y; - return (vec2.x > rect.x && vec2.x < rect.x + rect.width && vec2.y > rect.y && vec2.y < rect.y + rect.height); - } - - public static Vector2 firstTouch(){ - if(Input.touchCount>0){ - return Input.touches[0].position; - }else if(Input.GetMouseButton(0)){ - return Input.mousePosition; - } - - return new Vector2(Mathf.NegativeInfinity,Mathf.NegativeInfinity); - } + public static int RECT_LEVELS = 5; + public static int RECTS_PER_LEVEL = 10; + public static int BUTTONS_MAX = 24; + + private static LTRect[] levels; + private static int[] levelDepths; + private static Rect[] buttons; + private static int[] buttonLevels; + private static int[] buttonLastFrame; + private static LTRect r; + private static Color color = Color.white; + private static bool isGUIEnabled = false; + private static int global_counter = 0; + + public enum Element_Type{ + Texture, + Label + } + + public static void init(){ + if(levels==null){ + levels = new LTRect[RECT_LEVELS*RECTS_PER_LEVEL]; + levelDepths = new int[RECT_LEVELS]; + } + } + + public static void initRectCheck(){ + if(buttons==null){ + buttons = new Rect[BUTTONS_MAX]; + buttonLevels = new int[BUTTONS_MAX]; + buttonLastFrame = new int[BUTTONS_MAX]; + for(int i = 0; i < buttonLevels.Length; i++){ + buttonLevels[i] = -1; + } + } + } + + public static void reset(){ + if(isGUIEnabled){ + isGUIEnabled = false; + for(int i = 0; i < levels.Length; i++){ + levels[i] = null; + } + + for(int i = 0; i < levelDepths.Length; i++){ + levelDepths[i] = 0; + } + } + } + + public static void update( int updateLevel ){ + if(isGUIEnabled){ + init(); + if(levelDepths[updateLevel]>0){ + color = GUI.color; + int baseI = updateLevel*RECTS_PER_LEVEL; + int maxLoop = baseI + levelDepths[updateLevel];// RECTS_PER_LEVEL;//; + + for(int i = baseI; i < maxLoop; i++){ + r = levels[i]; + // Debug.Log("r:"+r+" i:"+i); + if(r!=null /*&& checkOnScreen(r.rect)*/){ + //Debug.Log("label:"+r.labelStr+" textColor:"+r.style.normal.textColor); + if(r.useColor) + GUI.color = r.color; + if(r.type == Element_Type.Label){ + if(r.style!=null) + GUI.skin.label = r.style; + if(r.useSimpleScale){ + GUI.Label( new Rect((r.rect.x + r.margin.x + r.relativeRect.x)*r.relativeRect.width, (r.rect.y + r.margin.y + r.relativeRect.y)*r.relativeRect.height, r.rect.width*r.relativeRect.width, r.rect.height*r.relativeRect.height), r.labelStr ); + }else{ + GUI.Label( new Rect(r.rect.x + r.margin.x, r.rect.y + r.margin.y, r.rect.width, r.rect.height), r.labelStr ); + } + }else if(r.type == Element_Type.Texture && r.texture!=null){ + Vector2 size = r.useSimpleScale ? new Vector2(0f, r.rect.height*r.relativeRect.height) : new Vector2(r.rect.width, r.rect.height); + if(r.sizeByHeight){ + size.x = (float)r.texture.width/(float)r.texture.height * size.y; + } + if(r.useSimpleScale){ + GUI.DrawTexture( new Rect((r.rect.x + r.margin.x + r.relativeRect.x)*r.relativeRect.width, (r.rect.y + r.margin.y + r.relativeRect.y)*r.relativeRect.height, size.x, size.y), r.texture ); + }else{ + GUI.DrawTexture( new Rect(r.rect.x + r.margin.x, r.rect.y + r.margin.y, size.x, size.y), r.texture ); + } + } + } + } + GUI.color = color; + } + } + } + + public static bool checkOnScreen(Rect rect){ + bool offLeft = rect.x + rect.width < 0f; + bool offRight = rect.x > Screen.width; + bool offBottom = rect.y > Screen.height; + bool offTop = rect.y + rect.height < 0f; + + return !(offLeft || offRight || offBottom || offTop); + } + + public static void destroy( int id ){ + int backId = id & 0xFFFF; + int backCounter = id >> 16; + if(id>=0 && levels[backId]!=null && levels[backId].hasInitiliazed && levels[backId].counter==backCounter) + levels[backId] = null; + } + + public static void destroyAll( int depth ){ // clears all gui elements on depth + int maxLoop = depth*RECTS_PER_LEVEL + RECTS_PER_LEVEL; + for(int i = depth*RECTS_PER_LEVEL; levels!=null && i < maxLoop; i++){ + levels[i] = null; + } + } + + public static LTRect label( Rect rect, string label, int depth){ + return LTGUI.label(new LTRect(rect), label, depth); + } + + public static LTRect label( LTRect rect, string label, int depth){ + rect.type = Element_Type.Label; + rect.labelStr = label; + return element(rect, depth); + } + + public static LTRect texture( Rect rect, Texture texture, int depth){ + return LTGUI.texture( new LTRect(rect), texture, depth); + } + + public static LTRect texture( LTRect rect, Texture texture, int depth){ + rect.type = Element_Type.Texture; + rect.texture = texture; + return element(rect, depth); + } + + public static LTRect element( LTRect rect, int depth){ + isGUIEnabled = true; + init(); + int maxLoop = depth*RECTS_PER_LEVEL + RECTS_PER_LEVEL; + int k = 0; + if(rect!=null){ + destroy(rect.id); + } + if(rect.type==LTGUI.Element_Type.Label && rect.style!=null){ + if(rect.style.normal.textColor.a<=0f){ + Debug.LogWarning("Your GUI normal color has an alpha of zero, and will not be rendered."); + } + } + if(rect.relativeRect.width==float.PositiveInfinity){ + rect.relativeRect = new Rect(0f,0f,Screen.width,Screen.height); + } + for(int i = depth*RECTS_PER_LEVEL; i < maxLoop; i++){ + r = levels[i]; + if(r==null){ + r = rect; + r.rotateEnabled = true; + r.alphaEnabled = true; + r.setId( i, global_counter ); + levels[i] = r; + // Debug.Log("k:"+k+ " maxDepth:"+levelDepths[depth]); + if(k>=levelDepths[depth]){ + levelDepths[depth] = k + 1; + } + global_counter++; + return r; + } + k++; + } + + Debug.LogError("You ran out of GUI Element spaces"); + + return null; + } + + public static bool hasNoOverlap( Rect rect, int depth ){ + initRectCheck(); + bool hasNoOverlap = true; + bool wasAddedToList = false; + for(int i = 0; i < buttonLevels.Length; i++){ + // Debug.Log("buttonLastFrame["+i+"]:"+buttonLastFrame[i]); + //Debug.Log("buttonLevels["+i+"]:"+buttonLevels[i]); + if(buttonLevels[i]>=0){ + //Debug.Log("buttonLastFrame["+i+"]:"+buttonLastFrame[i]+" Time.frameCount:"+Time.frameCount); + if( buttonLastFrame[i] + 1 < Time.frameCount ){ // It has to have been visible within the current, or + buttonLevels[i] = -1; + // Debug.Log("resetting i:"+i); + }else{ + //if(buttonLevels[i]>=0) + // Debug.Log("buttonLevels["+i+"]:"+buttonLevels[i]); + if(buttonLevels[i]>depth){ + /*if(firstTouch().x > 0){ + Debug.Log("buttons["+i+"]:"+buttons[i] + " firstTouch:"); + Debug.Log(firstTouch()); + Debug.Log(buttonLevels[i]); + }*/ + if(pressedWithinRect( buttons[i] )){ + hasNoOverlap = false; // there is an overlapping button that is higher + } + } + } + } + + if(wasAddedToList==false && buttonLevels[i]<0){ + wasAddedToList = true; + buttonLevels[i] = depth; + buttons[i] = rect; + buttonLastFrame[i] = Time.frameCount; + } + } + + return hasNoOverlap; + } + + public static bool pressedWithinRect( Rect rect ){ + Vector2 vec2 = firstTouch(); + if(vec2.x<0f) + return false; + float vecY = Screen.height-vec2.y; + return (vec2.x > rect.x && vec2.x < rect.x + rect.width && vecY > rect.y && vecY < rect.y + rect.height); + } + + public static bool checkWithinRect(Vector2 vec2, Rect rect){ + vec2.y = Screen.height-vec2.y; + return (vec2.x > rect.x && vec2.x < rect.x + rect.width && vec2.y > rect.y && vec2.y < rect.y + rect.height); + } + + public static Vector2 firstTouch(){ + if(Input.touchCount>0){ + return Input.touches[0].position; + }else if(Input.GetMouseButton(0)){ + return Input.mousePosition; + } + + return new Vector2(Mathf.NegativeInfinity,Mathf.NegativeInfinity); + } } + +namespace DentedPixel { public class LeanDummy {} } +//} diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs.meta b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs.meta index 7f4fba2c..bf901658 100644 --- a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs.meta +++ b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 9c2f4b27196f84954b44753aaac214bb -timeCreated: 1445946121 +timeCreated: 1463137984 licenseType: Store MonoImporter: serializedVersion: 2 diff --git a/Assets/Fungus/Thirdparty/LeanTween/LeanTween.dll.zip b/Assets/Fungus/Thirdparty/LeanTween/LeanTween.dll.zip new file mode 100644 index 0000000000000000000000000000000000000000..029cde1f8a42e9fa43f0d7cdf57bfdeae8c76b3d GIT binary patch literal 30942 zcmV)ZK&!t{O9KQH00;mG0LNJ_N&o-=000000000001W^T08C|JZd7+=Wo|BHY;09n z3;?@RdRSFXdRX-V6aehK31C!3@;~11y_q+6GLvH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JFQh~WXfFN{obhtj?_6W+#AVNy^oGf`gKs`r zXXmlzvHqf4C1G3a(PYs{nqO;dK;?-iA!b9e;jagkVIXk*JpA#=`W@WRkIF?KIt2GC zd1Q|Vy?OqS_rWAP9-d!$KCOq#F{xb zR`qiaIdsgi^{weq@Y-g+Qxj%ZW5UokxhZF0z;uYY2!4nJ(Km=NCcmHBp(O5jS=Ml zx2Y3SV`R&W&83+SHFC-<&|(JvQ-zZ^-?Y=g|9+>lJXjtS z9j0p8`TR@5)sxFaE~%$oR29d^%@XdH;fI1mLThp|8`ROwvI3?O96c{OMT%ktQVM%j zvCYgB2Ydu4mp#4JyK7k#-{pjTchxi${ZWIMyKdnVZ>QN$F5QT9)+}yZwnV9#X#h5Mx7sH6 zkBX7TB+{XWz`d&trr3I`yx%P4uYrrC&KIW`>+?tlmy764{x(H=5Y_GwZVj!z`RQz> zF((~);o^J@p6C^@6jC*=GoLe_*dWyWuii8ds}gh6UvhI>;zIPsM1Bs%a%jzmOtNN&4twH9@|6+~u-t_{ zo6GqM@0x?a=#UP}xP>{JsFkaA2aSb~`rYS-wRIuoSpDLrL0K9h*YQn6 z!Ebp1CfAt3A8f8dA<@ro3p9Plq3}BDsA%r*PJlvwuv){m@Nhcn@UZ=V|9=VM|N9yi p+`Ip`AhFCT;C~LeanTween Documentation - -Getting Started - - There are many examples included! Look in the “LeanTween/LeanTweenExamples" folder to see many of the methods outlined. diff --git a/Assets/Fungus/Thirdparty/LeanTween/ReadMe.txt.meta b/Assets/Fungus/Thirdparty/LeanTween/ReadMe.txt.meta deleted file mode 100644 index c08c74a3..00000000 --- a/Assets/Fungus/Thirdparty/LeanTween/ReadMe.txt.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: f1e0da947b69648fdb1884d602088d92