cancel() public static method

public static cancel ( GameObject gameObject ) : void
gameObject GameObject
return void
Ejemplo n.º 1
0
 void onExit()
 {
     LeanTween.cancel(animUI);
     LeanTween.scale(animUI, origScale, exitAnimTime).setEase(LeanTweenType.easeOutQuint);
 }
Ejemplo n.º 2
0
        private IEnumerator IEAlignByTweener(Action onFinish)
        {
            Init();

            if (Math.Abs(mChildren.Length * cellDistance) > maxContainerWidth && maxContainerWidth > 0)
            {
                cellDistance *= maxContainerWidth / (Math.Abs(mChildren.Length * cellDistance));
            }

            Vector3[] childrenNewPosition = new Vector3[mChildren.Length];
            Vector3[] childrenPrePosition = new Vector3[mChildren.Length];
            switch (alignmentType)
            {
            case Alignment.Left:
                for (int i = 0; i < mChildren.Length; i++)
                {
                    childrenPrePosition[i] = mChildren[i].localPosition;
                    childrenNewPosition[i] = i * new Vector3(cellDistance, yOffset, 0);
                }
                break;

            case Alignment.Right:
                for (int i = 0; i < mChildren.Length; i++)
                {
                    childrenPrePosition[i] = mChildren[i].localPosition;
                    childrenNewPosition[i] = (mChildren.Length - 1 - i) * new Vector3(cellDistance, yOffset, 0) * -1;
                }
                break;

            case Alignment.Center:
                for (int i = 0; i < mChildren.Length; i++)
                {
                    childrenPrePosition[i] = mChildren[i].localPosition;
                    childrenNewPosition[i] = i * new Vector3(cellDistance, yOffset, 0);
                }
                for (int i = 0; i < mChildren.Length; i++)
                {
                    childrenNewPosition[i] = new Vector3(
                        childrenNewPosition[i].x - childrenNewPosition[mChildren.Length - 1].x / 2,
                        childrenNewPosition[i].y + yOffset,
                        childrenNewPosition[i].z);
                }
                break;
            }

#if USE_LEANTWEEN
            LeanTween.cancel(gameObject);
            LeanTween.value(gameObject, 0f, 1f, 0.25f)
            .setOnUpdate((float val) =>
            {
                for (int j = 0; j < mChildren.Length; j++)
                {
                    var pos = Vector3.Lerp(childrenPrePosition[j], childrenNewPosition[j], val);
                    mChildren[j].localPosition = pos;
                }
            });
#elif USE_DOTWEEN
            float lerp = 0;
            DOTween.Kill(GetInstanceID());
            DOTween.To(tweenVal => lerp = tweenVal, 0f, 1f, 0.25f)
            .OnUpdate(() =>
            {
                for (int j = 0; j < mChildren.Length; j++)
                {
                    Vector2 pos = Vector2.Lerp(childrenPrePosition[j], childrenNewPosition[j], lerp);
                    mChildren[j].localPosition = pos;
                }
            })
            .SetEase(Ease.InQuint)
            .SetId(GetInstanceID());
#else
            if (mCoroutine != null)
            {
                StopCoroutine(mCoroutine);
            }
            mCoroutine = StartCoroutine(IEArrangeChildren(childrenPrePosition, childrenNewPosition, 0.25f));
#endif

            yield return(new WaitForSeconds(0.25f));

            if (onFinish != null)
            {
                onFinish();
            }
        }
Ejemplo n.º 3
0
 private void CancelColorLeanTween()
 {
     LeanTween.cancel(ColorLTDescr.id);
 }
 public void ResetFader()
 {
     LeanTween.cancel(gameObject);
     img.color = initialColor;
     fadeStyle = FadeStyle.FadeOut;
 }
Ejemplo n.º 5
0
 public void OnPointerExit(PointerEventData eventData)
 {
     LeanTween.cancel(delay.uniqueId);
     TooltipSystem.Hide();
 }
Ejemplo n.º 6
0
        IEnumerator lotsOfCancels()
        {
            yield return(new WaitForEndOfFrame());

            Time.timeScale = 4f;
            int cubeCount = 10;

            int[]        tweensA = new int[cubeCount];
            GameObject[] aGOs    = new GameObject[cubeCount];
            for (int i = 0; i < aGOs.Length; i++)
            {
                GameObject cube = Instantiate(boxNoCollider) as GameObject;
                cube.transform.position = new Vector3(0, 0, i * 2f);
                cube.name  = "a" + i;
                aGOs[i]    = cube;
                tweensA[i] = LeanTween.move(cube, cube.transform.position + new Vector3(10f, 0, 0), 0.5f + 1f * (1.0f / (float)aGOs.Length)).id;
                LeanTween.color(cube, Color.red, 0.01f);
            }

            yield return(new WaitForSeconds(1.0f));

            int[]        tweensB = new int[cubeCount];
            GameObject[] bGOs    = new GameObject[cubeCount];
            for (int i = 0; i < bGOs.Length; i++)
            {
                GameObject cube = Instantiate(boxNoCollider) as GameObject;
                cube.transform.position = new Vector3(0, 0, i * 2f);
                cube.name  = "b" + i;
                bGOs[i]    = cube;
                tweensB[i] = LeanTween.move(cube, cube.transform.position + new Vector3(10f, 0, 0), 2f).id;
            }

            for (int i = 0; i < aGOs.Length; i++)
            {
                LeanTween.cancel(aGOs[i]);
                GameObject cube = aGOs[i];
                tweensA[i] = LeanTween.move(cube, new Vector3(0, 0, i * 2f), 2f).id;
            }

            yield return(new WaitForSeconds(0.5f));

            for (int i = 0; i < aGOs.Length; i++)
            {
                LeanTween.cancel(aGOs[i]);
                GameObject cube = aGOs[i];
                tweensA[i] = LeanTween.move(cube, new Vector3(0, 0, i * 2f) + new Vector3(10f, 0, 0), 2f).id;
            }

            for (int i = 0; i < bGOs.Length; i++)
            {
                LeanTween.cancel(bGOs[i]);
                GameObject cube = bGOs[i];
                tweensB[i] = LeanTween.move(cube, new Vector3(0, 0, i * 2f), 2f).id;
            }

            yield return(new WaitForSeconds(2.1f));

            bool inFinalPlace = true;

            for (int i = 0; i < aGOs.Length; i++)
            {
                if (Vector3.Distance(aGOs[i].transform.position, new Vector3(0, 0, i * 2f) + new Vector3(10f, 0, 0)) > 0.1f)
                {
                    inFinalPlace = false;
                }
            }

            for (int i = 0; i < bGOs.Length; i++)
            {
                if (Vector3.Distance(bGOs[i].transform.position, new Vector3(0, 0, i * 2f)) > 0.1f)
                {
                    inFinalPlace = false;
                }
            }

            LeanTest.expect(inFinalPlace, "AFTER LOTS OF CANCELS");

            GameObject cubePaused = cubeNamed("cPaused");

            cubePaused.LeanMoveX(10f, 1f).setOnComplete(() => {
                pauseTweenDidFinish = true;
            });
            StartCoroutine(pauseTimeNow());
        }
    public void StopAnimate()
    {
        LeanTween.cancel(gameObject);

        LeanTween.scale(gameObject, startScale, stopTime).setEase(curveType);
    }
Ejemplo n.º 8
0
 public void MakeHidden()
 {
     LeanTween.cancel(ltID);
     ltID = LeanTween.alphaCanvas(canvasGroup, 0, .05f).setEase(leanTweenType).id;
 }
Ejemplo n.º 9
0
 public void LerpToColor(Color color)
 {
     targetColor = color;
     LeanTween.cancel(ltColorID);
     ltColorID = LeanTween.value(this.gameObject, UpdateTTColor, image.color, color, .05f).setEase(leanTweenType).id;
 }
Ejemplo n.º 10
0
 public void OnPointerExit(PointerEventData pointerEventData)
 {
     LeanTween.cancel(gameObject);
     LeanTween.scale(gameObject, originalScale * (1 - animationGrowth), animationSpeed * 2).setFrom(originalScale).setLoopPingPong().setEaseInOutSine();
 }
Ejemplo n.º 11
0
    void OnTriggerEnter2D(Collider2D cols)
    {
        string objCol = cols.gameObject.name;

        if (!activeGodMode)
        {
            if (objCol.Equals(redss))
            {
                gameManager.CounterLogic(1);
                LeanTween.cancel(cols.gameObject);
                spwnY       = gameManager.SpawnPoint[Random.Range(0, gameManager.SpawnPoint.Length)].transform.position.y;
                confSpwnPos = cols.gameObject.transform.position;
                cols.gameObject.SetActive(false);
                confetti.TriggerConfettis(confSpwnPos);
                cols.gameObject.transform.position = new Vector3(gameManager.SpawnPoint[0].position.x, spwnY, 0f);
            }
            if (objCol.Equals(whitess) || objCol.Equals(donuts))
            {
                gameManager.ScreenShake();
                cols.gameObject.SetActive(false);
                gameManager.CounterLogic(0);
                LeanTween.cancel(cols.gameObject);
                spwnY = gameManager.SpawnPoint[Random.Range(0, gameManager.SpawnPoint.Length)].transform.position.y;
                cols.gameObject.transform.position = new Vector3(gameManager.SpawnPoint[0].position.x, spwnY, 0f);
            }
            if (objCol.Equals(obsOne) || objCol.Equals(obsFourss))
            {
                gameManager.CounterLogic(0);
                gameManager.ScreenShake();
            }
            if (powaState)
            {
                if (objCol.Equals(powa))
                {
                    rorPow.ResetPos();
                    gameManager.ScreenShake();
                    gameManager.BonusTimer();
                    godModeProjectile.SetActive(true);
                    ResetColliderSize(true, 1);
                }
            }
        }
        else
        {
            if (objCol.Equals(redss))
            {
                gameManager.ScreenShake();
                spwnY       = gameManager.SpawnPoint[Random.Range(0, gameManager.SpawnPoint.Length)].transform.position.y;
                confSpwnPos = cols.gameObject.transform.position;
                LeanTween.cancel(cols.gameObject);
                cols.gameObject.SetActive(false);
                confetti.TriggerConfettis(confSpwnPos);
                cols.gameObject.transform.position = new Vector3(gameManager.SpawnPoint[0].position.x, spwnY, gameManager.SpawnPoint[0].position.z);
                gameManager.CounterLogic(1);
            }
            if (objCol.Equals(whitess) || objCol.Equals(donuts))
            {
                gameManager.ScreenShake();
                spwnY       = gameManager.SpawnPoint[Random.Range(0, gameManager.SpawnPoint.Length)].transform.position.y;
                confSpwnPos = cols.gameObject.transform.position;
                LeanTween.cancel(cols.gameObject);
                cols.gameObject.SetActive(false);
                confetti.TriggerConfettis(confSpwnPos);
                cols.gameObject.transform.position = new Vector3(gameManager.SpawnPoint[0].position.x, spwnY, gameManager.SpawnPoint[0].position.z);
                gameManager.CounterLogic(1);
            }
        }
    }
Ejemplo n.º 12
0
 void OnDisable()
 {
     LeanTween.cancel(gameObject);
 }
Ejemplo n.º 13
0
    public void SetActiveChoiceHero(bool boolean)
    {
#if TEST
        Debug.Log(boolean);
#endif

        PanelChoiceHero.interactable  = boolean;
        PanelChoiceSpell.interactable = boolean;
        if (boolean)
        {
#if TEST
            Debug.Log(boolean);
#endif
            TableChoice.SetActive(true);

            if (tweenScale != null)
            {
                LeanTween.cancel(TableChoice, tweenScale.uniqueId);
                tweenScale = null;
            }
            tweenScale = LeanTween.scale(TableChoice, vector_tablechoice, 0.2f).setOnComplete(() =>
            {
                tweenScale = null;
                tweenScale = LeanTween.scale(imageVS, Vector3.zero, 0.2f).setOnComplete(() =>
                {
                    tweenScale = null;
                });
            }).setEase(LeanTweenType.easeOutBack).setOnCompleteOnStart(true);
            if (tweenAlpha != null)
            {
                LeanTween.cancel(TableChoice, tweenAlpha.uniqueId);
                tweenAlpha = null;
            }
            tweenAlpha = LeanTween.alphaCanvas(tableChoiceCanvas, 1, 0.2f).setOnComplete(() =>
            {
                //tweenAlpha = LeanTween.alphaCanvas(TableChoice.GetComponent<CanvasGroup>(), 1, 0.2f).setOnComplete(() => {
                tweenAlpha = null;
            });
        }
        else
        {
#if TEST
            Debug.Log(boolean);
#endif
            TableChoice.SetActive(true);
            if (tweenScale != null)
            {
                LeanTween.cancel(TableChoice, tweenScale.uniqueId);
                tweenScale = null;
            }
            tweenScale = LeanTween.scale(TableChoice, Vector3.zero, 0.2f).setOnComplete(() =>
            {
                tweenScale = null;
                tableChoiceCanvas.alpha = 0;
                tweenScale = LeanTween.scale(imageVS, Vector3.one, 0.2f).setEase(LeanTweenType.easeInOutBack).setOnComplete(() =>
                {
                    tweenScale = null;
                });
            }).setEase(LeanTweenType.easeInBack).setOnCompleteOnStart(true);
        }
    }
Ejemplo n.º 14
0
 void onSubmit()
 {
     LeanTween.cancel(animUI);
     LeanTween.scale(animUI, origScale, submitAnimTime).setEase(LeanTweenType.easeOutBack);
 }
Ejemplo n.º 15
0
        IEnumerator timeBasedTesting()
        {
            yield return(new WaitForEndOfFrame());

            GameObject cubeNormal = cubeNamed("normalTimeScale");

            // float timeElapsedNormal = Time.time;
            LeanTween.moveX(cubeNormal, 12f, 1.5f).setIgnoreTimeScale(false).setOnComplete(() => {
                timeElapsedNormalTimeScale = Time.time;
            });

            LTDescr[] descr = LeanTween.descriptions(cubeNormal);
            LeanTest.expect(descr.Length >= 0 && descr[0].to.x == 12f, "WE CAN RETRIEVE A DESCRIPTION");

            GameObject cubeIgnore = cubeNamed("ignoreTimeScale");

            LeanTween.moveX(cubeIgnore, 5f, 1.5f).setIgnoreTimeScale(true).setOnComplete(() => {
                timeElapsedIgnoreTimeScale = Time.time;
            });

            yield return(new WaitForSeconds(1.5f));

            LeanTest.expect(Mathf.Abs(timeElapsedNormalTimeScale - timeElapsedIgnoreTimeScale) < 0.7f, "START IGNORE TIMING", "timeElapsedIgnoreTimeScale:" + timeElapsedIgnoreTimeScale + " timeElapsedNormalTimeScale:" + timeElapsedNormalTimeScale);

            //          yield return new WaitForSeconds(100f);
            Time.timeScale = 4f;

            int pauseCount = 0;

            LeanTween.value(gameObject, 0f, 1f, 1f).setOnUpdate((float val) => {
                pauseCount++;
            }).pause();

            // Bezier should end at exact end position not just 99% close to it
            Vector3[]  roundCirc  = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(-9.1f, 25.1f, 0f), new Vector3(-1.2f, 15.9f, 0f), new Vector3(-25f, 25f, 0f), new Vector3(-25f, 25f, 0f), new Vector3(-50.1f, 15.9f, 0f), new Vector3(-40.9f, 25.1f, 0f), new Vector3(-50f, 0f, 0f), new Vector3(-50f, 0f, 0f), new Vector3(-40.9f, -25.1f, 0f), new Vector3(-50.1f, -15.9f, 0f), new Vector3(-25f, -25f, 0f), new Vector3(-25f, -25f, 0f), new Vector3(0f, -15.9f, 0f), new Vector3(-9.1f, -25.1f, 0f), new Vector3(0f, 0f, 0f) };
            GameObject cubeRound  = cubeNamed("bRound");
            Vector3    onStartPos = cubeRound.transform.position;

            LeanTween.moveLocal(cubeRound, roundCirc, 0.5f).setOnComplete(() => {
                LeanTest.expect(cubeRound.transform.position == onStartPos, "BEZIER CLOSED LOOP SHOULD END AT START", "onStartPos:" + onStartPos + " onEnd:" + cubeRound.transform.position);
            });

            // should be able to retrieve a point
            LTBezierPath roundCircPath = new LTBezierPath(roundCirc);
            float        ratioPoint    = roundCircPath.ratioAtPoint(new Vector3(-25f, 25f, 0f));

            LeanTest.expect(Mathf.Equals(ratioPoint, 0.25f), "BEZIER RATIO POINT");

            // Spline should end at exact end position not just 99% close to it
            Vector3[]  roundSpline      = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(2f, 0f, 0f), new Vector3(0.9f, 2f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f) };
            GameObject cubeSpline       = cubeNamed("bSpline");
            Vector3    onStartPosSpline = cubeSpline.transform.position;

            LeanTween.moveSplineLocal(cubeSpline, roundSpline, 0.5f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(onStartPosSpline, cubeSpline.transform.position) <= 0.01f, "SPLINE CLOSED LOOP SHOULD END AT START", "onStartPos:" + onStartPosSpline + " onEnd:" + cubeSpline.transform.position + " dist:" + Vector3.Distance(onStartPosSpline, cubeSpline.transform.position));
            });

            // Sequence test, do three tweens and make sure they end at the right points
            GameObject cubeSeq = cubeNamed("cSeq");
            var        seq     = LeanTween.sequence().append(LeanTween.moveX(cubeSeq, 100f, 0.2f));

            seq.append(0.1f).append(LeanTween.scaleX(cubeSeq, 2f, 0.1f));
            seq.append(() => {
                LeanTest.expect(cubeSeq.transform.position.x == 100f, "SEQ MOVE X FINISHED", "move x:" + cubeSeq.transform.position.x);
                LeanTest.expect(cubeSeq.transform.localScale.x == 2f, "SEQ SCALE X FINISHED", "scale x:" + cubeSeq.transform.localScale.x);
            }).setScale(0.2f);

            // Bounds check
            GameObject cubeBounds    = cubeNamed("cBounds");
            bool       didPassBounds = true;
            Vector3    failPoint     = Vector3.zero;

            LeanTween.move(cubeBounds, new Vector3(10, 10, 10), 0.1f).setOnUpdate((float val) => {
                //              //Debug.LogWarning("cubeBounds x:"+cubeBounds.transform.position.x + " y:"+ cubeBounds.transform.position.y+" z:"+cubeBounds.transform.position.z);
                if (cubeBounds.transform.position.x < 0f || cubeBounds.transform.position.x > 10f || cubeBounds.transform.position.y < 0f || cubeBounds.transform.position.y > 10f || cubeBounds.transform.position.z < 0f || cubeBounds.transform.position.z > 10f)
                {
                    didPassBounds = false;
                    failPoint     = cubeBounds.transform.position;
                    //                  //Debug.LogError("OUT OF BOUNDS");
                }
            }).setLoopPingPong().setRepeat(8).setOnComplete(() => {
                LeanTest.expect(didPassBounds, "OUT OF BOUNDS", "pos x:" + failPoint.x + " y:" + failPoint.y + " z:" + failPoint.z);
            });

            // Local scale check
            //GameObject cubeLocal = cubeNamed("cLocal");
            //LeanTween.scale(cubeLocal, new Vector3(0.5f, 0.5f, 0.5f), 0.2f).setOnComplete(() =>
            //{
            //    LeanTest.expect((cubeLocal.transform.localScale.x == 0.5f && cubeLocal.transform.localScale.y == 0.5f && cubeLocal.transform.localScale.z == 0.5f), "SCALE WORKS", "scale x:" + cubeLocal.transform.localScale.x + " y:" + cubeLocal.transform.localScale.y + " z:" + cubeLocal.transform.localScale.z);
            //});

            // Groups of tweens testing
            groupTweens    = new LTDescr[1200];
            groupGOs       = new GameObject[groupTweens.Length];
            groupTweensCnt = 0;
            int descriptionMatchCount = 0;

            for (int i = 0; i < groupTweens.Length; i++)
            {
                GameObject cube = cubeNamed("c" + i);
                cube.transform.position = new Vector3(0, 0, i * 3);

                groupGOs[i] = cube;
            }

            yield return(new WaitForEndOfFrame());

            bool hasGroupTweensCheckStarted = false;
            int  setOnStartNum  = 0;
            int  setPosNum      = 0;
            bool setPosOnUpdate = true;

            for (int i = 0; i < groupTweens.Length; i++)
            {
                Vector3 finalPos = transform.position + Vector3.one * 3f;
                Dictionary <string, object> finalDict = new Dictionary <string, object> {
                    { "final", finalPos }, { "go", groupGOs[i] }
                };
                groupTweens[i] = LeanTween.move(groupGOs[i], finalPos, 3f).setOnStart(() => {
                    setOnStartNum++;
                }).setOnUpdate((Vector3 newPosition) => {
                    if (transform.position.z > newPosition.z)
                    {
                        setPosOnUpdate = false;
                    }
                    //                  //Debug.LogWarning("New Position: " + newPosition.ToString());
                }).
                                 setOnCompleteParam(finalDict).
                                 setOnComplete((object param) => {
                    Dictionary <string, object> finalDictRetr = param as Dictionary <string, object>;
                    Vector3 neededPos    = (Vector3)finalDictRetr["final"];
                    GameObject tweenedGo = finalDictRetr["go"] as GameObject;
                    if (neededPos.ToString() == tweenedGo.transform.position.ToString())
                    {
                        setPosNum++;
                    }
                    else
                    {
                        //                      //Debug.Log("neededPos:"+neededPos+" tweenedGo.transform.position:"+tweenedGo.transform.position);
                    }
                    if (hasGroupTweensCheckStarted == false)
                    {
                        hasGroupTweensCheckStarted = true;
                        LeanTween.delayedCall(gameObject, 0.1f, () => {
                            LeanTest.expect(setOnStartNum == groupTweens.Length, "SETONSTART CALLS", "expected:" + groupTweens.Length + " was:" + setOnStartNum);
                            LeanTest.expect(groupTweensCnt == groupTweens.Length, "GROUP FINISH", "expected " + groupTweens.Length + " tweens but got " + groupTweensCnt);
                            LeanTest.expect(setPosNum == groupTweens.Length, "GROUP POSITION FINISH", "expected " + groupTweens.Length + " tweens but got " + setPosNum);
                            LeanTest.expect(setPosOnUpdate, "GROUP POSITION ON UPDATE");
                        });
                    }
                    groupTweensCnt++;
                });

                if (LeanTween.description(groupTweens[i].id).trans == groupTweens[i].trans)
                {
                    descriptionMatchCount++;
                }
            }

            while (LeanTween.tweensRunning < groupTweens.Length)
            {
                yield return(null);
            }

            LeanTest.expect(descriptionMatchCount == groupTweens.Length, "GROUP IDS MATCH");
            int expectedSearch = groupTweens.Length + 7;

            LeanTest.expect(LeanTween.maxSearch <= expectedSearch, "MAX SEARCH OPTIMIZED", "maxSearch:" + LeanTween.maxSearch + " should be:" + expectedSearch);
            LeanTest.expect(LeanTween.isTweening() == true, "SOMETHING IS TWEENING");

            // resume item before calling pause should continue item along it's way
            float previousXlt4 = cube4.transform.position.x;

            lt4 = LeanTween.moveX(cube4, 5.0f, 1.1f).setOnComplete(() => {
                LeanTest.expect(cube4 != null && previousXlt4 != cube4.transform.position.x, "RESUME OUT OF ORDER", "cube4:" + cube4 + " previousXlt4:" + previousXlt4 + " cube4.transform.position.x:" + (cube4 != null ? cube4.transform.position.x : 0));
            }).setDestroyOnComplete(true);
            lt4.resume();

            rotateRepeat = rotateRepeatAngle = 0;
            LeanTween.rotateAround(cube3, Vector3.forward, 360f, 0.1f).setRepeat(3).setOnComplete(rotateRepeatFinished).setOnCompleteOnRepeat(true).setDestroyOnComplete(true);
            yield return(new WaitForEndOfFrame());

            LeanTween.delayedCall(0.1f * 8f + 1f, rotateRepeatAllFinished);

            int countBeforeCancel = LeanTween.tweensRunning;

            LeanTween.cancel(lt1Id);
            LeanTest.expect(countBeforeCancel == LeanTween.tweensRunning, "CANCEL AFTER RESET SHOULD FAIL", "expected " + countBeforeCancel + " but got " + LeanTween.tweensRunning);
            LeanTween.cancel(cube2);

            int tweenCount = 0;

            for (int i = 0; i < groupTweens.Length; i++)
            {
                if (LeanTween.isTweening(groupGOs[i]))
                {
                    tweenCount++;
                }
                if (i % 3 == 0)
                {
                    LeanTween.pause(groupGOs[i]);
                }
                else if (i % 3 == 1)
                {
                    groupTweens[i].pause();
                }
                else
                {
                    LeanTween.pause(groupTweens[i].id);
                }
            }
            LeanTest.expect(tweenCount == groupTweens.Length, "GROUP ISTWEENING", "expected " + groupTweens.Length + " tweens but got " + tweenCount);

            yield return(new WaitForEndOfFrame());

            tweenCount = 0;
            for (int i = 0; i < groupTweens.Length; i++)
            {
                if (i % 3 == 0)
                {
                    LeanTween.resume(groupGOs[i]);
                }
                else if (i % 3 == 1)
                {
                    groupTweens[i].resume();
                }
                else
                {
                    LeanTween.resume(groupTweens[i].id);
                }

                if (i % 2 == 0 ? LeanTween.isTweening(groupTweens[i].id) : LeanTween.isTweening(groupGOs[i]))
                {
                    tweenCount++;
                }
            }
            LeanTest.expect(tweenCount == groupTweens.Length, "GROUP RESUME");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "CANCEL TWEEN LTDESCR");
            LeanTest.expect(LeanTween.isTweening(cube2) == false, "CANCEL TWEEN LEANTWEEN");

            LeanTest.expect(pauseCount == 0, "ON UPDATE NOT CALLED DURING PAUSE", "expect pause count of 0, but got " + pauseCount);


            yield return(new WaitForEndOfFrame());

            Time.timeScale = 0.25f;
            float tweenTime         = 0.2f;
            float expectedTime      = tweenTime * (1f / Time.timeScale);
            float start             = Time.realtimeSinceStartup;
            bool  onUpdateWasCalled = false;

            LeanTween.moveX(cube1, -5f, tweenTime).setOnUpdate((float val) => {
                onUpdateWasCalled = true;
            }).setOnComplete(() => {
                float end  = Time.realtimeSinceStartup;
                float diff = end - start;

                LeanTest.expect(Mathf.Abs(expectedTime - diff) < 0.06f, "SCALED TIMING DIFFERENCE", "expected to complete in roughly " + expectedTime + " but completed in " + diff);
                LeanTest.expect(Mathf.Approximately(cube1.transform.position.x, -5f), "SCALED ENDING POSITION", "expected to end at -5f, but it ended at " + cube1.transform.position.x);
                LeanTest.expect(onUpdateWasCalled, "ON UPDATE FIRED");
            });

            bool didGetCorrectOnUpdate = false;

            LeanTween.value(gameObject, new Vector3(1f, 1f, 1f), new Vector3(10f, 10f, 10f), 1f).setOnUpdate((Vector3 val) => {
                didGetCorrectOnUpdate = val.x >= 1f && val.y >= 1f && val.z >= 1f;
            }).setOnComplete(() => {
                LeanTest.expect(didGetCorrectOnUpdate, "VECTOR3 CALLBACK CALLED");
            });

            yield return(new WaitForSeconds(expectedTime));

            Time.timeScale = 1f;

            int ltCount = 0;

            GameObject[] allGos = FindObjectsOfType(typeof(GameObject)) as GameObject[];
            foreach (GameObject go in allGos)
            {
                if (go.name == "~LeanTween")
                {
                    ltCount++;
                }
            }
            LeanTest.expect(ltCount == 1, "RESET CORRECTLY CLEANS UP");

            StartCoroutine(lotsOfCancels());
        }
Ejemplo n.º 16
0
 public void Deactivate()
 {
     LeanTween.cancel(gameObject);
     gameObject.SetActive(false);
 }
Ejemplo n.º 17
0
        void Start()
        {
            //          Time.timeScale = 0.25f;

            LeanTest.timeout  = 46f;
            LeanTest.expected = 62;

            LeanTween.init(1300);

            // add a listener
            LeanTween.addListener(cube1, 0, eventGameObjectCalled);

            LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

            LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
                LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
            });

            // dispatch event that is received
            LeanTween.dispatchEvent(0);
            LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

            // do not remove listener
            LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
            // remove listener
            LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

            // add a listener
            LeanTween.addListener(1, eventGeneralCalled);

            // dispatch event that is received
            LeanTween.dispatchEvent(1);
            LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

            // remove listener
            LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

            lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
            LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

            LeanTween.reset();

            // Queue up a bunch of tweens, cancel some of them but expect the remainder to finish
            GameObject[] cubes    = new GameObject[99];
            int[]        tweenIds = new int[cubes.Length];
            for (int i = 0; i < cubes.Length; i++)
            {
                GameObject c = cubeNamed("cancel" + i);
                tweenIds[i] = LeanTween.moveX(c, 100f, 1f).id;
                cubes[i]    = c;
            }
            int onCompleteCount = 0;

            LeanTween.delayedCall(cubes[0], 0.2f, () => {
                for (int i = 0; i < cubes.Length; i++)
                {
                    if (i % 3 == 0)
                    {
                        LeanTween.cancel(cubes[i]);
                    }
                    else if (i % 3 == 1)
                    {
                        LeanTween.cancel(tweenIds[i]);
                    }
                    else if (i % 3 == 2)
                    {
                        LTDescr descr = LeanTween.descr(tweenIds[i]);
                        //                      //Debug.Log("descr:"+descr);
                        descr.setOnComplete(() => {
                            onCompleteCount++;
                            //                          //Debug.Log("onCompleteCount:"+onCompleteCount);
                            if (onCompleteCount >= 33)
                            {
                                LeanTest.expect(true, "CANCELS DO NOT EFFECT FINISHING");
                            }
                        });
                    }
                }
            });

            Vector3[] splineArr = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) };
            LTSpline  cr        = new LTSpline(splineArr);

            cr.place(cube4.transform, 0.5f);
            LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
            LeanTween.color(cube4, Color.green, 0.01f);

            //          //Debug.Log("Point 2:"+cr.ratioAtPoint(splineArr[2]));

            // OnStart Speed Test for ignoreTimeScale vs normal timeScale

            GameObject cubeDest    = cubeNamed("cubeDest");
            Vector3    cubeDestEnd = new Vector3(100f, 20f, 0f);

            LeanTween.move(cubeDest, cubeDestEnd, 0.7f);

            GameObject cubeToTrans = cubeNamed("cubeToTrans");

            LeanTween.move(cubeToTrans, cubeDest.transform, 1.2f).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => {
                LeanTest.expect(cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS");
            });

            GameObject cubeDestroy = cubeNamed("cubeDestroy");

            LeanTween.moveX(cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true);
            LeanTween.moveX(cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete(() => {
                LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED");
            });

            GameObject cubeSpline = cubeNamed("cubeSpline");

            LeanTween.moveSpline(cubeSpline, new Vector3[] { new Vector3(0.5f, 0f, 0.5f), new Vector3(0.75f, 0f, 0.75f), new Vector3(1f, 0f, 1f), new Vector3(1f, 0f, 1f) }, 0.1f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(new Vector3(1f, 0f, 1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS");
            });

            // This test works when it is positioned last in the test queue (probably worth fixing when you have time)
            GameObject jumpCube = cubeNamed("jumpTime");

            jumpCube.transform.position    = new Vector3(100f, 0f, 0f);
            jumpCube.transform.localScale *= 100f;
            int jumpTimeId = LeanTween.moveX(jumpCube, 200f, 1f).id;

            LeanTween.delayedCall(gameObject, 0.2f, () => {
                LTDescr d     = LeanTween.descr(jumpTimeId);
                float beforeX = jumpCube.transform.position.x;
                d.setTime(0.5f);
                LeanTween.delayedCall(0.0f, () => { }).setOnStart(() => {
                    float diffAmt = 1f;// This variable is dependent on a good frame-rate because it evalutes at the next Update
                    beforeX      += Time.deltaTime * 100f * 2f;
                    LeanTest.expect(Mathf.Abs(jumpCube.transform.position.x - beforeX) < diffAmt, "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:" + Mathf.Abs(jumpCube.transform.position.x - beforeX) + " beforeX:" + beforeX + " now:" + jumpCube.transform.position.x + " dt:" + Time.deltaTime);
                });
            });

            // Tween with time of zero is needs to be set to it's final value
            GameObject zeroCube = cubeNamed("zeroCube");

            LeanTween.moveX(zeroCube, 10f, 0f).setOnComplete(() => {
                LeanTest.expect(zeroCube.transform.position.x == 10f, "ZERO TIME FINSHES CORRECTLY", "final x:" + zeroCube.transform.position.x);
            });

            // Scale, and OnStart
            GameObject cubeScale = cubeNamed("cubeScale");

            LeanTween.scale(cubeScale, new Vector3(5f, 5f, 5f), 0.01f).setOnStart(() => {
                LeanTest.expect(true, "ON START WAS CALLED");
            }).setOnComplete(() => {
                LeanTest.expect(cubeScale.transform.localScale.z == 5f, "SCALE", "expected scale z:" + 5f + " returned:" + cubeScale.transform.localScale.z);
            });

            // Rotate
            GameObject cubeRotate = cubeNamed("cubeRotate");

            LeanTween.rotate(cubeRotate, new Vector3(0f, 180f, 0f), 0.02f).setOnComplete(() => {
                LeanTest.expect(cubeRotate.transform.eulerAngles.y == 180f, "ROTATE", "expected rotate y:" + 180f + " returned:" + cubeRotate.transform.eulerAngles.y);
            });

            // RotateAround
            GameObject cubeRotateA = cubeNamed("cubeRotateA");

            LeanTween.rotateAround(cubeRotateA, Vector3.forward, 90f, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeRotateA.transform.eulerAngles.z == 90f, "ROTATE AROUND", "expected rotate z:" + 90f + " returned:" + cubeRotateA.transform.eulerAngles.z);
            });

            // RotateAround 360
            GameObject cubeRotateB = cubeNamed("cubeRotateB");

            cubeRotateB.transform.position = new Vector3(200f, 10f, 8f);
            LeanTween.rotateAround(cubeRotateB, Vector3.forward, 360f, 0.3f).setPoint(new Vector3(5f, 3f, 2f)).setOnComplete(() => {
                LeanTest.expect(cubeRotateB.transform.position.ToString() == (new Vector3(200f, 10f, 8f)).ToString(), "ROTATE AROUND 360", "expected rotate pos:" + (new Vector3(200f, 10f, 8f)) + " returned:" + cubeRotateB.transform.position);
            });

            // Alpha, onUpdate with passing value, onComplete value
            LeanTween.alpha(cubeAlpha1, 0.5f, 0.1f).setOnUpdate((float val) => {
                LeanTest.expect(val != 0f, "ON UPDATE VAL");
            }).setOnCompleteParam("Hi!").setOnComplete((object completeObj) => {
                LeanTest.expect(((string)completeObj) == "Hi!", "ONCOMPLETE OBJECT");
                LeanTest.expect(cubeAlpha1.GetComponent <Renderer>().material.color.a == 0.5f, "ALPHA");
            });
            // Color
            float onStartTime = -1f;

            LeanTween.color(cubeAlpha2, Color.cyan, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.GetComponent <Renderer>().material.color == Color.cyan, "COLOR");
                LeanTest.expect(onStartTime >= 0f && onStartTime < Time.time, "ON START", "onStartTime:" + onStartTime + " time:" + Time.time);
            }).setOnStart(() => {
                onStartTime = Time.time;
            });
            // moveLocalY (make sure uses y values)
            Vector3 beforePos = cubeAlpha1.transform.position;

            LeanTween.moveY(cubeAlpha1, 3f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha1.transform.position.x == beforePos.x && cubeAlpha1.transform.position.z == beforePos.z, "MOVE Y");
            });

            Vector3 beforePos2 = cubeAlpha2.transform.localPosition;

            LeanTween.moveLocalZ(cubeAlpha2, 12f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.transform.localPosition.x == beforePos2.x && cubeAlpha2.transform.localPosition.y == beforePos2.y, "MOVE LOCAL Z", "ax:" + cubeAlpha2.transform.localPosition.x + " bx:" + beforePos.x + " ay:" + cubeAlpha2.transform.localPosition.y + " by:" + beforePos2.y);
            });

            AudioClip audioClip = LeanAudio.createAudio(new AnimationCurve(new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f)), new AnimationCurve(new Keyframe(0f, 0.001f, 0f, 0f), new Keyframe(1f, 0.001f, 0f, 0f)), LeanAudio.options());

            LeanTween.delayedSound(gameObject, audioClip, new Vector3(0f, 0f, 0f), 0.1f).setDelay(0.2f).setOnComplete(() => {
                LeanTest.expect(Time.time > 0, "DELAYED SOUND");
            });

            // Easing Methods
            int totalEasingCheck        = 0;
            int totalEasingCheckSuccess = 0;

            for (int j = 0; j < 2; j++)
            {
                bool isCheckingFrom       = j == 1;
                int  totalTweenTypeLength = (int)LeanTweenType.easeShake;
                for (int i = (int)LeanTweenType.notUsed; i < totalTweenTypeLength; i++)
                {
                    LeanTweenType easeType = (LeanTweenType)i;
                    GameObject    cube     = cubeNamed("cube" + easeType);
                    LTDescr       descr    = LeanTween.moveLocalX(cube, 5, 0.1f).setOnComplete((object obj) => {
                        GameObject cubeIn = obj as GameObject;
                        totalEasingCheck++;
                        if (cubeIn.transform.position.x == 5f)
                        {
                            totalEasingCheckSuccess++;
                        }
                        if (totalEasingCheck == (2 * totalTweenTypeLength))
                        {
                            LeanTest.expect(totalEasingCheck == totalEasingCheckSuccess, "EASING TYPES");
                        }
                    }).setOnCompleteParam(cube);

                    if (isCheckingFrom)
                    {
                        descr.setFrom(-5f);
                    }
                }
            }

            // value2
            bool value2UpdateCalled = false;

            LeanTween.value(gameObject, new Vector2(0, 0), new Vector2(256, 96), 0.1f).setOnUpdate((Vector2 value) => {
                value2UpdateCalled = true;
            });
            LeanTween.delayedCall(0.2f, () => {
                LeanTest.expect(value2UpdateCalled, "VALUE2 UPDATE");
            });

            // check descr
            //          LTDescr descr2 = LeanTween.descr( descrId );
            //          LeanTest.expect(descr2 == null,"DESCRIPTION STARTS AS NULL");

            StartCoroutine(timeBasedTesting());
        }
Ejemplo n.º 18
0
    IEnumerator StoryRoutine()
    {
        Camera.main.GetComponent <CameraController>().FadeScreen(true, Color.black, 3f);

        yield return(new WaitForSeconds(5f));

        yield return(StartCoroutine(DisplayCaption("Up until that day, nobody suspected a thing.", 5f)));

        yield return(new WaitForSeconds(1f));

        yield return(StartCoroutine(DisplayCaption("The seabed was only explored by madmen..", 5f)));

        yield return(new WaitForSeconds(1f));

        yield return(StartCoroutine(DisplayCaption("..Who never returned from their voyage.", 5f)));

        yield return(new WaitForSeconds(1f));

        yield return(StartCoroutine(DisplayCaption("On that day, everything changed..", 5f)));

        yield return(new WaitForSeconds(1f));

        yield return(StartCoroutine(DisplayCaption("..When THEY attacked.", 5f)));

        // yield return new WaitForSeconds(7f);

        StopCoroutine("TweenBoat");
        LeanTween.cancel(boatObject);
        boatTweening = false;

        // TentacleTake

        // Track1 (Translation)
        GameObject track2OBJ = GameObject.Find("spr_Tentacle");

        track2OBJ.transform.position = new Vector3(3.967498f, -3.840069f, 0f); // Set Initial Position
        AMTween.MoveTo(track2OBJ, AMTween.Hash("delay", 0f, "time", 2.041667f, "position", new Vector3(3.162237f, -2.531516f, 0f), "easetype", "easeInOutQuad"));
        AMTween.MoveTo(track2OBJ, AMTween.Hash("delay", 2.041667f, "time", 2.083333f, "position", new Vector3(-2.45f, 1.24f, 0f), "easetype", "easeInOutQuad"));
        AMTween.MoveTo(track2OBJ, AMTween.Hash("delay", 4.125f, "time", 0.4166667f, "position", new Vector3(-4.714787f, -0.3956867f, 0f), "easetype", "easeInOutQuad"));
        AMTween.MoveTo(track2OBJ, AMTween.Hash("delay", 4.541667f, "time", 0.2083333f, "position", new Vector3(-4.714782f, -5.977065f, 0f), "easetype", "linear"));

        // Track2 (Rotation)
        GameObject track3OBJ = track2OBJ;                              // or use GameObject.Find("spr_Tentacle");

        track3OBJ.transform.rotation = new Quaternion(0f, 0f, 0f, 1f); // Set Initial Rotation
        AMTween.RotateTo(track3OBJ, AMTween.Hash("delay", 4.125f, "time", 0.4166667f, "rotation", new Vector3(0f, 0f, 40.79998f), "easetype", "linear"));

        // Track3 (Translation)
        GameObject track4OBJ = GameObject.Find("spr_Boat");

        track4OBJ.transform.position = new Vector3(-5.402687f, -0.8655984f, 0f); // Set Initial Position
        AMTween.MoveTo(track4OBJ, AMTween.Hash("delay", 4.625f, "time", 0.125f, "position", new Vector3(-5.402687f, -3.73f, 0f), "easetype", "linear"));

        yield return(new WaitForSeconds(6f));

        Camera.main.GetComponent <CameraController>().FadeScreen(false, Color.black, 6f);
        yield return(new WaitForSeconds(8f));

        Application.LoadLevel("MainScene");

        yield return(0);
    }
Ejemplo n.º 19
0
 public void CancelAnimations()
 {
     LeanTween.cancel(gameObject);
 }
Ejemplo n.º 20
0
 public static void LeanCancel <T>(this T component) where T : Component
 {
     LeanTween.cancel(component.gameObject);
 }
Ejemplo n.º 21
0
        public void StopAnimate()
        {
            LeanTween.cancel(gameObject);

            LeanTween.move(gameObject, startPosition, stopTime).setEase(curveType);
        }
Ejemplo n.º 22
0
        IEnumerator timeBasedTesting()
        {
            yield return(new WaitForEndOfFrame());

            GameObject cubeNormal = cubeNamed("normalTimeScale");

            // float timeElapsedNormal = Time.time;
            LeanTween.moveX(cubeNormal, 12f, 1.5f).setIgnoreTimeScale(false).setOnComplete(() => {
                timeElapsedNormalTimeScale = Time.time;
            });

            LTDescr[] descr = LeanTween.descriptions(cubeNormal);
            LeanTest.expect(descr.Length >= 0 && descr[0].to.x == 12f, "WE CAN RETRIEVE A DESCRIPTION");

            GameObject cubeIgnore = cubeNamed("ignoreTimeScale");

            LeanTween.moveX(cubeIgnore, 5f, 1.5f).setIgnoreTimeScale(true).setOnComplete(() => {
                timeElapsedIgnoreTimeScale = Time.time;
            });

            yield return(new WaitForSeconds(1.5f));

            LeanTest.expect(Mathf.Abs(timeElapsedNormalTimeScale - timeElapsedIgnoreTimeScale) < 0.7f, "START IGNORE TIMING", "timeElapsedIgnoreTimeScale:" + timeElapsedIgnoreTimeScale + " timeElapsedNormalTimeScale:" + timeElapsedNormalTimeScale);

//			yield return new WaitForSeconds(100f);
            Time.timeScale = 4f;

            int pauseCount = 0;

            LeanTween.value(gameObject, 0f, 1f, 1f).setOnUpdate(( float val ) => {
                pauseCount++;
            }).pause();

            // Bezier should end at exact end position not just 99% close to it
            Vector3[]  roundCirc  = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(-9.1f, 25.1f, 0f), new Vector3(-1.2f, 15.9f, 0f), new Vector3(-25f, 25f, 0f), new Vector3(-25f, 25f, 0f), new Vector3(-50.1f, 15.9f, 0f), new Vector3(-40.9f, 25.1f, 0f), new Vector3(-50f, 0f, 0f), new Vector3(-50f, 0f, 0f), new Vector3(-40.9f, -25.1f, 0f), new Vector3(-50.1f, -15.9f, 0f), new Vector3(-25f, -25f, 0f), new Vector3(-25f, -25f, 0f), new Vector3(0f, -15.9f, 0f), new Vector3(-9.1f, -25.1f, 0f), new Vector3(0f, 0f, 0f) };
            GameObject cubeRound  = cubeNamed("bRound");
            Vector3    onStartPos = cubeRound.transform.position;

            LeanTween.moveLocal(cubeRound, roundCirc, 0.5f).setOnComplete(() => {
                LeanTest.expect(cubeRound.transform.position == onStartPos, "BEZIER CLOSED LOOP SHOULD END AT START", "onStartPos:" + onStartPos + " onEnd:" + cubeRound.transform.position);
            });

            // Spline should end at exact end position not just 99% close to it
            Vector3[]  roundSpline      = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(2f, 0f, 0f), new Vector3(0.9f, 2f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f) };
            GameObject cubeSpline       = cubeNamed("bSpline");
            Vector3    onStartPosSpline = cubeSpline.transform.position;

            LeanTween.moveSplineLocal(cubeSpline, roundSpline, 0.5f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(onStartPosSpline, cubeSpline.transform.position) <= 0.01f, "SPLINE CLOSED LOOP SHOULD END AT START", "onStartPos:" + onStartPosSpline + " onEnd:" + cubeSpline.transform.position + " dist:" + Vector3.Distance(onStartPosSpline, cubeSpline.transform.position));
            });

            // Groups of tweens testing
            groupTweens    = new LTDescr[1200];
            groupGOs       = new GameObject[groupTweens.Length];
            groupTweensCnt = 0;
            int descriptionMatchCount = 0;

            for (int i = 0; i < groupTweens.Length; i++)
            {
                GameObject cube = cubeNamed("c" + i);
                cube.transform.position = new Vector3(0, 0, i * 3);

                groupGOs[i] = cube;
            }

            yield return(new WaitForEndOfFrame());

            bool hasGroupTweensCheckStarted = false;
            int  setOnStartNum = 0;

            for (int i = 0; i < groupTweens.Length; i++)
            {
                groupTweens[i] = LeanTween.move(groupGOs[i], transform.position + Vector3.one * 3f, 3f).setOnStart(() => {
                    setOnStartNum++;
                }).setOnComplete(() => {
                    if (hasGroupTweensCheckStarted == false)
                    {
                        hasGroupTweensCheckStarted = true;
                        LeanTween.delayedCall(gameObject, 0.1f, () => {
                            LeanTest.expect(setOnStartNum == groupTweens.Length, "SETONSTART CALLS", "expected:" + groupTweens.Length + " was:" + setOnStartNum);
                            LeanTest.expect(groupTweensCnt == groupTweens.Length, "GROUP FINISH", "expected " + groupTweens.Length + " tweens but got " + groupTweensCnt);
                        });
                    }
                    groupTweensCnt++;
                });

                if (LeanTween.description(groupTweens[i].id).trans == groupTweens[i].trans)
                {
                    descriptionMatchCount++;
                }
            }

            while (LeanTween.tweensRunning < groupTweens.Length)
            {
                yield return(null);
            }

            LeanTest.expect(descriptionMatchCount == groupTweens.Length, "GROUP IDS MATCH");
            int expectedSearch = groupTweens.Length + 5;

            LeanTest.expect(LeanTween.maxSearch <= expectedSearch, "MAX SEARCH OPTIMIZED", "maxSearch:" + LeanTween.maxSearch + " should be:" + expectedSearch);
            LeanTest.expect(LeanTween.isTweening() == true, "SOMETHING IS TWEENING");

            // resume item before calling pause should continue item along it's way
            float previousXlt4 = cube4.transform.position.x;

            lt4 = LeanTween.moveX(cube4, 5.0f, 1.1f).setOnComplete(() => {
                LeanTest.expect(cube4 != null && previousXlt4 != cube4.transform.position.x, "RESUME OUT OF ORDER", "cube4:" + cube4 + " previousXlt4:" + previousXlt4 + " cube4.transform.position.x:" + (cube4 != null ? cube4.transform.position.x : 0));
            }).setDestroyOnComplete(true);
            lt4.resume();

            rotateRepeat = rotateRepeatAngle = 0;
            LeanTween.rotateAround(cube3, Vector3.forward, 360f, 0.1f).setRepeat(3).setOnComplete(rotateRepeatFinished).setOnCompleteOnRepeat(true).setDestroyOnComplete(true);
            yield return(new WaitForEndOfFrame());

            LeanTween.delayedCall(0.1f * 8f + 1f, rotateRepeatAllFinished);

            int countBeforeCancel = LeanTween.tweensRunning;

            LeanTween.cancel(lt1Id);
            LeanTest.expect(countBeforeCancel == LeanTween.tweensRunning, "CANCEL AFTER RESET SHOULD FAIL", "expected " + countBeforeCancel + " but got " + LeanTween.tweensRunning);
            LeanTween.cancel(cube2);

            int tweenCount = 0;

            for (int i = 0; i < groupTweens.Length; i++)
            {
                if (LeanTween.isTweening(groupGOs[i]))
                {
                    tweenCount++;
                }
                if (i % 3 == 0)
                {
                    LeanTween.pause(groupGOs[i]);
                }
                else if (i % 3 == 1)
                {
                    groupTweens[i].pause();
                }
                else
                {
                    LeanTween.pause(groupTweens[i].id);
                }
            }
            LeanTest.expect(tweenCount == groupTweens.Length, "GROUP ISTWEENING", "expected " + groupTweens.Length + " tweens but got " + tweenCount);

            yield return(new WaitForEndOfFrame());

            tweenCount = 0;
            for (int i = 0; i < groupTweens.Length; i++)
            {
                if (i % 3 == 0)
                {
                    LeanTween.resume(groupGOs[i]);
                }
                else if (i % 3 == 1)
                {
                    groupTweens[i].resume();
                }
                else
                {
                    LeanTween.resume(groupTweens[i].id);
                }

                if (i % 2 == 0 ? LeanTween.isTweening(groupTweens[i].id) : LeanTween.isTweening(groupGOs[i]))
                {
                    tweenCount++;
                }
            }
            LeanTest.expect(tweenCount == groupTweens.Length, "GROUP RESUME");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "CANCEL TWEEN LTDESCR");
            LeanTest.expect(LeanTween.isTweening(cube2) == false, "CANCEL TWEEN LEANTWEEN");

            LeanTest.expect(pauseCount == 0, "ON UPDATE NOT CALLED DURING PAUSE", "expect pause count of 0, but got " + pauseCount);

            yield return(new WaitForEndOfFrame());

            Time.timeScale = 0.25f;
            float tweenTime         = 0.2f;
            float expectedTime      = tweenTime * (1f / Time.timeScale);
            float start             = Time.realtimeSinceStartup;
            bool  onUpdateWasCalled = false;

            LeanTween.moveX(cube1, -5f, tweenTime).setOnUpdate((float val) => {
                onUpdateWasCalled = true;
            }).setOnComplete(() => {
                float end  = Time.realtimeSinceStartup;
                float diff = end - start;

                LeanTest.expect(Mathf.Abs(expectedTime - diff) < 0.05f, "SCALED TIMING DIFFERENCE", "expected to complete in roughly " + expectedTime + " but completed in " + diff);
                LeanTest.expect(Mathf.Approximately(cube1.transform.position.x, -5f), "SCALED ENDING POSITION", "expected to end at -5f, but it ended at " + cube1.transform.position.x);
                LeanTest.expect(onUpdateWasCalled, "ON UPDATE FIRED");
            });

            bool didGetCorrectOnUpdate = false;

            LeanTween.value(gameObject, new Vector3(1f, 1f, 1f), new Vector3(10f, 10f, 10f), 1f).setOnUpdate(( Vector3 val ) => {
                didGetCorrectOnUpdate = val.x >= 1f && val.y >= 1f && val.z >= 1f;
            }).setOnComplete(() => {
                LeanTest.expect(didGetCorrectOnUpdate, "VECTOR3 CALLBACK CALLED");
            });

            yield return(new WaitForSeconds(expectedTime));

            Time.timeScale = 1f;

            int ltCount = 0;

            GameObject[] allGos = FindObjectsOfType(typeof(GameObject)) as GameObject[];
            foreach (GameObject go in allGos)
            {
                if (go.name == "~LeanTween")
                {
                    ltCount++;
                }
            }
            LeanTest.expect(ltCount == 1, "RESET CORRECTLY CLEANS UP");

            lotsOfCancels();
        }
 public void PlayPingpong()
 {
     LeanTween.cancel(gameObject);
     transform.localScale = DefaultScale * m_range.From;
     LeanTween.scale(gameObject, DefaultScale * m_range.To, m_animTime).setLoopPingPong().setIgnoreTimeScale(m_AnimIgnoreTimeScale);
 }
Ejemplo n.º 24
0
 public static void InterriptPrev(MonoBehaviour mb)
 {
     LeanTween.cancel(mb.gameObject, false);
 }
Ejemplo n.º 25
0
 // Stops pulsing the object
 public void StopPulsing(GameObject go)
 {
     LeanTween.cancel(go);
 }
Ejemplo n.º 26
0
 public static void InterriptPrev(GameObject go)
 {
     LeanTween.cancel(go, false);
 }
Ejemplo n.º 27
0
    public void StopAnimation()
    {
        LeanTween.scale(gameObject, _originalScale, 0f).setSpeed(speed).setEase(tweenType);

        LeanTween.cancel(gameObject);
    }
Ejemplo n.º 28
0
 void OnDestroy()
 {
     LeanTween.cancel(gameObject);
 }
Ejemplo n.º 29
0
 public void StopCamera()
 {
     LeanTween.cancel(gameObject);
 }
Ejemplo n.º 30
0
 void onPress()
 {
     LeanTween.cancel(animUI);
     LeanTween.scale(animUI, origScale * pushScale, enterAnimTime).setEase(LeanTweenType.easeOutQuint);
 }