IEnumerator Rotate(float angle, float rotationTime) { clockwise = !clockwise; if (tweenID != 0) { LeanTween.pause(tweenID); tweaningPaused = true; yield return(new WaitForSeconds(stopTimer)); tweaningPaused = false; LeanTween.resume(tweenID); } if (clockwise) { tweenID = LeanTween.rotateAroundLocal(gameObject, Vector3.forward, angle, rotationTime).id; } else { tweenID = LeanTween.rotateAroundLocal(gameObject, Vector3.back, angle, rotationTime).id; } yield return(null); }
//===================================================== #region IPauseListener public void OnPauseEvent(bool isPaused) { _isPaused = isPaused; if (_cameraPathAnimator != null) { // Manage active fly-thru switch (_isPaused) { case true: _cameraPathAnimator.Pause(); break; case false: _cameraPathAnimator.Play(); break; } return; } if (_isCameraFollowingPath == false) { return; } // Manage active tween if (_isPaused == true && _tweenId != -1) { LeanTween.pause(_tweenId); } else if (_isPaused == false && _tweenId != -1) { LeanTween.resume(_tweenId); } }
protected override void _ResumeGame() { if (currentMicro != null) { currentMicro.Resume(); } LeanTween.resume(finger.gameObject); if (isTransitioning) { if (currentMicro != null) { foreach (SpriteRenderer sprRenderer in backgrounds[currentMicro.Background].GetComponentsInChildren <SpriteRenderer>()) { LeanTween.resume(sprRenderer.gameObject); } } LeanTween.resume(monsterBackground); LeanTween.resume(monsterBody); monsterBody.GetComponentInChildren <Animator>().enabled = true; if (isParticlePaused) { monsterParticle.Play(); } } }
private void HideConnectingLayer() { LeanTween.resume(FindObjectOfType <Parallax>().foreground.gameObject); LeanTween.resume(FindObjectOfType <Parallax>().background.gameObject); menuManager.serverCover.gameObject.SetActive(false); }
IEnumerator WarningState() { warningState = true; LeanTween.pause(tweenID); // Pysäytetään kameran rotaatio spriteRenderer.sprite = viewConeWarningSprite; cameraLight.color = warningColor; cameraLight.intensity = 0.8f; StartCoroutine(LerpViewConeSize(originalSize * warningConeMultiplier)); // Muutetaan viewconen kokoa suuremmaksi yield return(new WaitForSeconds(safetyTimer)); // Katsotaan onko tietyn ajan kuluessa Warning-tila päällä eli onko pelaaja näkökentässä //StopCoroutine("LerpViewConeSize"); if (warningState) { StartCoroutine(AlarmState()); // Laitetaan kamera seuraamaan pelaajaa } else if (!alarmState) { spriteRenderer.sprite = viewConeSafeSprite; cameraLight.color = safeColor; cameraLight.intensity = 0.5f; StartCoroutine(LerpViewConeSize(originalSize)); yield return(new WaitForSeconds(0.5f)); LeanTween.resume(tweenID); } yield return(null); }
public void UnPause() { enabled = true; if (mLeanTweenActiveAnimID1 != -1) { LeanTween.resume(mLeanTweenActiveAnimID1); } }
private void FadeInAndStartShield() { if (!shieldIsOn) { shieldIsOn = true; LeanTween.alpha(gameObject, 1, 1f); LeanTween.resume(pingPongAnimation); } }
public void StartTap(Vector3 tapPosition) { LeanTween.resume(gameObject); if (!tapping) { tapping = true; SetupTap(tapPosition); } }
protected override void _Resume() { if (petInstance) { petInstance.GetComponentInChildren <Animator>().enabled = true; } LeanTween.resume(inhalerButton); LeanTween.resume(dayBackground); LeanTween.resume(nightBackground); }
public void ResumeAnimations() { for (int i = 0; i < texts.Length; ++i) { if (!texts[i].gameObject.activeInHierarchy) { continue; } LeanTween.resume(texts[i].gameObject); } }
private void Update() { if (Input.GetKeyDown(KeyCode.A)) { LeanTween.resume(id); } if (Input.GetKeyDown(KeyCode.D)) { LeanTween.resume(fid); } }
void Update() { // work around for enemies who spawn during a state change they seem to miss the event call when this happens if(ShooterGameManager.Instance.IsPaused) { LeanTween.pause(this.gameObject); } else { LeanTween.resume(this.gameObject); } if(ShooterGameManager.Instance.isGameOver) { StartCoroutine(DestroyEnemy()); } }
public void setPieceState() { warningState = false; alarmState = false; spriteRenderer.sprite = viewConeSafeSprite; cameraLight.color = safeColor; cameraLight.intensity = 0.5f; StartCoroutine(LerpViewConeSize(originalSize)); LeanTween.resume(tweenID); }
void Update() { if (Input.GetKeyDown(KeyCode.A)) { // Debug.Log("id:"+id); LeanTween.resume(id); } if (Input.GetKeyDown(KeyCode.D)) { LeanTween.resume(fid); } }
//===================================================== #region IPauseListener public void OnPauseEvent(bool isPaused) { // Manage active tween if (isPaused == true && _tweenId != -1) { LeanTween.pause(_tweenId); } else if (isPaused == false && _tweenId != -1) { LeanTween.resume(_tweenId); } }
IEnumerator AlarmState() { alarmState = true; warningState = false; spriteRenderer.sprite = viewConeAlarmSprite; cameraLight.color = AlertColor; cameraLight.intensity = 2f; StartCoroutine(LerpViewConeSize(originalSize * alarmConeMultiplier)); GetComponent <PolygonCollider2D>().enabled = false; enemyTriggerArea.SetActive(true); while (true) { if (player != null) { Vector3 dir = player.transform.position - transform.position; float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; Quaternion to = Quaternion.AngleAxis(angle + 90f, Vector3.forward); transform.rotation = Quaternion.Lerp(transform.rotation, to, Time.deltaTime * 5f); } else { warningState = false; alarmState = false; spriteRenderer.sprite = viewConeSafeSprite; cameraLight.color = safeColor; cameraLight.intensity = 0.5f; StartCoroutine(LerpViewConeSize(originalSize)); yield return(new WaitForSeconds(0.5f)); LeanTween.resume(tweenID); yield break; } yield return(null); } //while(alarmState) //{ // Vector3 dir = player.transform.position - transform.position; // float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; // transform.rotation = Quaternion.AngleAxis(angle + 90f, Vector3.forward); // yield return null; //} }
private void UnfreezeScoop() { Debug.Log("Attempting to unfreeze scoop : " + flavor + ". VerticalScoopTween is " + verticalScoopTween, gameObject); if (verticalScoopTween != null) { try { LeanTween.resume(verticalScoopTween.id); } catch (NullReferenceException e) { Debug.Log(e); return; } } }
public void PauseMove(bool value) { if (value) { LeanTween.pause(gameObject); } else { LeanTween.resume(gameObject); } Debug.Log("Is pause " + gameObject.name + ": " + LeanTween.isPaused(gameObject)); }
public void Play() { if (!isStartOnAwake) { isStartOnAwake = true; // Lock the init start functionality ResetSelf(); } else if (isPauseCheck) { isPauseCheck = false; LeanTween.resume(gameObject); } }
public void UnPause() { switch (curEnabledAnimInSequence) { case 0: LeanTween.resume(id1); break; case 1: LeanTween.resume(id2); break; case 2: LeanTween.resume(id3); break; default: break; } enabled = true; }
void Update() { //Cuando el slider llegue al maximo, escalar el icono if (CacaPorcentage.value >= 1.0f && !escalando) { transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); LeanTween.resume(leanID); escalando = true; s.Play(); } //Si no se esta escalando, dejar su escala en 1 if (escalando && startOver) { escalando = false; startOver = false; LeanTween.pause(leanID); transform.localScale = Vector3.one; s.Stop(); } }
// Update is called once per frame private IEnumerator StartLoadEndAnimation(int fadeInId, int fadeOutId, int hideMyCanvas) { var gameLevel = SceneManager.LoadSceneAsync(1); while (!gameLevel.isDone) { progressBar.value = Mathf.Clamp01(gameLevel.progress / 0.9f); yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(fadeDuration)); LeanTween.resume(fadeInId); yield return(new WaitForSeconds(fadeDuration + 0.1f)); LeanTween.resume(hideMyCanvas); LeanTween.resume(fadeOutId); yield return(new WaitForSeconds(fadeDuration)); Destroy(this.gameObject); }
//===================================================== #region IPauseListener public void OnPauseEvent(bool isPaused) { if (_isPlatformFollowingPath == false) { return; } if (_isPlatformActivated == false) { return; } // Manage active tween if (isPaused == true && _tweenId != -1) { LeanTween.pause(_tweenId); } else if (isPaused == false && _tweenId != -1) { LeanTween.resume(_tweenId); } }
public void SetActiveDayName(bool active, bool cancel = false) { if (!canvasDay.gameObject.activeInHierarchy) { return; } if (active) { LeanTween.resume(dayTween.id); } else { if (cancel) { LeanTween.cancel(dayTween.id); canvasDay.gameObject.SetActive(false); } else { LeanTween.pause(dayTween.id); } } }
public void loopResume() { GameObject cube1 = GameObject.Find("Cube1"); LeanTween.resume(cube1); }
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; 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 + 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(); }
//LeanTween.removeListener //LeanTween.resume public static void LeanResume(this GameObject gameObject) { LeanTween.resume(gameObject); }
public void Unpause() { anim.skeleton.timeScale = anim.savedTimeScale; LeanTween.resume(gameObject); }
IEnumerator timeBasedTesting() { yield return(new WaitForSeconds(1)); yield return(new WaitForEndOfFrame()); LeanTest.expect(Mathf.Abs(timeElapsedNormalTimeScale - timeElapsedIgnoreTimeScale) < 0.15f, "START IGNORE TIMING", "timeElapsedIgnoreTimeScale:" + timeElapsedIgnoreTimeScale + " timeElapsedNormalTimeScale:" + timeElapsedNormalTimeScale); 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 = Instantiate(boxNoCollider) as GameObject; cubeRound.name = "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 = Instantiate(boxNoCollider) as GameObject; cubeSpline.name = "bSpline"; Vector3 onStartPosSpline = cubeSpline.transform.position; LeanTween.moveSplineLocal(cubeSpline, roundSpline, 0.5f).setOnComplete(() => { LeanTest.expect(Vector3.Distance(onStartPosSpline, cubeSpline.transform.position) <= 0.01f, "BEZIER 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 = Instantiate(boxNoCollider) as GameObject; cube.name = "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"); LeanTest.expect(LeanTween.maxSearch <= groupTweens.Length + 5, "MAX SEARCH OPTIMIZED", "maxSearch:" + LeanTween.maxSearch); 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"); }); 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(); }
IEnumerator timeBasedTesting() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); Time.timeScale = 0.25f; float tweenTime = 0.2f; 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(tweenTime * (1f / Time.timeScale) - diff) < 0.05f, "SCALED TIMING DIFFERENCE", "expected to complete in roughly 0.8f 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"); }); yield return(new WaitForSeconds(1.0f)); Time.timeScale = 1f; // 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 = GameObject.CreatePrimitive(PrimitiveType.Cube); Destroy(cube.GetComponent(typeof(BoxCollider)) as Component); cube.transform.position = new Vector3(0, 0, i * 3); cube.name = "c" + i; groupGOs[i] = cube; groupTweens[i] = LeanTween.move(cube, transform.position + Vector3.one * 3f, 0.6f).setOnComplete(groupTweenFinished); if (LeanTween.description(groupTweens[i].id).trans == groupTweens[i].trans) { descriptionMatchCount++; } } LeanTween.delayedCall(gameObject, 0.82f, groupTweensFinished); LeanTest.expect(descriptionMatchCount == groupTweens.Length, "GROUP IDS MATCH"); LeanTest.expect(LeanTween.maxSearch <= groupTweens.Length + 5, "MAX SEARCH OPTIMIZED", "maxSearch:" + LeanTween.maxSearch); 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)); }); lt4.resume(); yield return(new WaitForSeconds(0.1f)); int countBeforeCancel = LeanTween.tweensRunning; lt1.cancel(); 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"); 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"); }