public static alpha ( GameObject gameObject, float to, float time ) : LTDescr, | ||
gameObject | GameObject | |
to | float | |
time | float | |
return | LTDescr, |
void FadeFinished() { LeanTween.alpha(tooFar, 0f, 1f).setEase(LeanTweenType.linear); }
/// <summary> /// Show portrait with the supplied portrait options /// </summary> /// <param name="options"></param> public virtual void Show(PortraitOptions options) { options = CleanPortraitOptions(options); if (options.shiftIntoPlace) { options.fromPosition = Instantiate(options.toPosition) as RectTransform; if (options.offset == PositionOffset.OffsetLeft) { options.fromPosition.anchoredPosition = new Vector2(options.fromPosition.anchoredPosition.x - Mathf.Abs(options.shiftOffset.x), options.fromPosition.anchoredPosition.y - Mathf.Abs(options.shiftOffset.y)); } else if (options.offset == PositionOffset.OffsetRight) { options.fromPosition.anchoredPosition = new Vector2(options.fromPosition.anchoredPosition.x + Mathf.Abs(options.shiftOffset.x), options.fromPosition.anchoredPosition.y + Mathf.Abs(options.shiftOffset.y)); } else { options.fromPosition.anchoredPosition = new Vector2(options.fromPosition.anchoredPosition.x, options.fromPosition.anchoredPosition.y); } } SetupPortrait(options); // LeanTween doesn't handle 0 duration properly float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon; // Fade out a duplicate of the existing portrait image if (options.character.State.portraitImage != null) { GameObject tempGO = GameObject.Instantiate(options.character.State.portraitImage.gameObject); tempGO.transform.SetParent(options.character.State.portraitImage.transform, false); tempGO.transform.localPosition = Vector3.zero; tempGO.transform.localScale = options.character.State.position.localScale; Image tempImage = tempGO.GetComponent <Image>(); tempImage.sprite = options.character.State.portraitImage.sprite; tempImage.preserveAspect = true; tempImage.color = options.character.State.portraitImage.color; LeanTween.alpha(tempImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType).setOnComplete(() => { Destroy(tempGO); }); } // Fade in the new sprite image if (options.character.State.portraitImage.sprite != options.portrait || options.character.State.portraitImage.color.a < 1f) { 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); } DoMoveTween(options); FinishCommand(options); if (!stage.CharactersOnStage.Contains(options.character)) { stage.CharactersOnStage.Add(options.character); } // Update character state after showing options.character.State.onScreen = true; options.character.State.display = DisplayType.Show; options.character.State.portrait = options.portrait; options.character.State.facing = options.facing; options.character.State.position = options.toPosition; }
// Start is called before the first frame update void Start() { onScreentext = GetComponentInChildren<Text>(); panelRect = GetComponent<RectTransform>(); LeanTween.alpha(panelRect, 0f, 0f).setEase(LeanTweenType.linear); }
public void Initialize(Vector3 from, Vector3 to) { transform.position = from; transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(to.y - from.y, to.x - from.x) * Mathf.Rad2Deg); fadeOut = false; spriteRenderer.color = new Color(1, 1, 1, 0); float distance = Vector2.Distance(from, to); float time = distance / 2; LeanTween.alpha(this.gameObject, 0.3f, time * 0.4f); LeanTween.move(this.gameObject, to, time).setOnUpdate((float val) => { if (val > 0.8f && fadeOut == false) { fadeOut = true; LeanTween.alpha(this.gameObject, 0f, time * 0.2f); } }).setOnComplete(() => Destroy(this.gameObject)); }
// Start is called before the first frame update private void OnEnable() { LeanTween.alpha(gameObject, 1f, .7f); }
private void FadeInNewTip() { LoadNewTip(); LeanTween.alpha(TipFadeObject, 0, AutomaticTipFadeTime).setEase(AutomaticTipTweenType); }
public void Flash() { LeanTween.alpha(_myRect, 1.0f, 2) .setLoopPingPong() .setEase(LeanTweenType.easeOutQuart); }
void heal() { collider.enabled = false; LeanTween.alpha(this.gameObject, 0, 1f).setOnComplete(() => Destroy(this.gameObject)); PlayerProperties.playerScript.healPlayer(healAmount); }
public void Previous(float time, float delay, LeanTweenType ease) { LeanTween.alpha(gameObject, _previousColor.a, time) .setDelay(delay) .setEase(ease); }
IEnumerator GachaFullAnimation() { //Fall downwards LeanTween.moveY(gameObject, -3.8f, 0.5f).setEase(LeanTweenType.easeOutCubic); yield return(new WaitForSeconds(0.5f)); //Float upwards, grow larger, fade screen sr.sortingLayerName = "Foreground"; sr.sortingOrder = 1; LeanTween.value(gameObject, 0, 0.5f, 1.5f).setOnUpdate((float value) => { machineKnob.fadeScreenImage.color = new Color(machineKnob.fadeScreenImage.color.r, machineKnob.fadeScreenImage.color.g, machineKnob.fadeScreenImage.color.b, value); }); LeanTween.moveY(gameObject, 3, 0.75f).setEase(LeanTweenType.easeOutCubic); LeanTween.scale(gameObject, transform.localScale * 2f, 0.75f).setEase(LeanTweenType.easeOutQuad); LeanTween.rotateZ(gameObject, 810, 0.75f).setEase(LeanTweenType.easeOutCubic); yield return(new WaitForSeconds(0.65f)); //Jut downwards LeanTween.moveY(gameObject, 0, 0.35f).setEase(LeanTweenType.easeInCubic); yield return(new WaitForSeconds(0.35f)); //Split open, revealing contents sr.enabled = false; machineKnob.playsound(2); GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraShakeHandler>().ShakeCamera(0.15f, 0.35f); lHalf = new GameObject("Left Half"); lHalf.AddComponent <SpriteRenderer>(); switch (receivedItems[0].rarity) { case Item.Rarity.Common: lHalf.GetComponent <SpriteRenderer>().sprite = commonCapsuleTop; break; case Item.Rarity.Uncommon: lHalf.GetComponent <SpriteRenderer>().sprite = uncommonCapsuleTop; break; case Item.Rarity.Rare: lHalf.GetComponent <SpriteRenderer>().sprite = rareCapsuleTop; break; case Item.Rarity.UltraRare: lHalf.GetComponent <SpriteRenderer>().sprite = ultraRareCapsuleTop; break; } lHalf.GetComponent <SpriteRenderer>().sortingLayerName = "Foreground"; lHalf.GetComponent <SpriteRenderer>().sortingOrder = 2; rHalf = new GameObject("Right Half"); rHalf.transform.eulerAngles = new Vector3(rHalf.transform.eulerAngles.x, rHalf.transform.eulerAngles.y, 90); rHalf.AddComponent <SpriteRenderer>().sprite = capsuleBottom; rHalf.GetComponent <SpriteRenderer>().flipX = true; rHalf.GetComponent <SpriteRenderer>().sortingLayerName = "Foreground"; rHalf.GetComponent <SpriteRenderer>().sortingOrder = 2; lHalf.transform.position = transform.position + Vector3.left; lHalf.transform.localScale *= 2; lHalf.transform.eulerAngles = new Vector3(lHalf.transform.eulerAngles.x, lHalf.transform.eulerAngles.y, 90); rHalf.transform.position = transform.position + Vector3.right; rHalf.transform.localScale *= 2; rHalf.transform.eulerAngles = new Vector3(rHalf.transform.eulerAngles.x, rHalf.transform.eulerAngles.y, 90); LeanTween.moveX(lHalf, lHalf.transform.position.x - 3, 0.5f).setEase(LeanTweenType.easeOutCubic); LeanTween.moveX(rHalf, rHalf.transform.position.x + 3, 0.5f).setEase(LeanTweenType.easeOutCubic); gachaItem = new GameObject("Gacha Item"); gachaItem.AddComponent <SpriteRenderer>().sprite = receivedItems[0].image; gachaItem.GetComponent <SpriteRenderer>().color = new Color(255, 255, 255, 0); gachaItem.GetComponent <SpriteRenderer>().sortingLayerName = "Foreground"; gachaItem.GetComponent <SpriteRenderer>().sortingOrder = 3; LeanTween.scale(gachaItem, gachaItem.transform.localScale * 2, 1.5f).setEase(LeanTweenType.easeOutCubic); LeanTween.alpha(gachaItem, 1, 0.25f).setEase(LeanTweenType.easeOutCubic); yield return(new WaitForSeconds(0.5f)); //Spawn text objects topText = Instantiate(topTextPrefab); topText.GetComponent <TextMeshProUGUI>().text = "You received:"; topText.transform.SetParent(GameObject.FindGameObjectWithTag("Text Canvas").transform, false); TextMeshProUGUI topTMP = topText.GetComponent <TextMeshProUGUI>(); topTMP.color = new Color(topTMP.color.r, topTMP.color.g, topTMP.color.b, 0); LeanTween.moveY(topText, transform.position.y + 3, 1.5f).setEase(LeanTweenType.easeOutCubic); LeanTween.scale(topText, new Vector2(3.5f, 3.5f), 1.5f).setEase(LeanTweenType.easeOutCubic); LeanTween.value(gameObject, 0, 1, 0.5f).setEase(LeanTweenType.easeOutCubic).setOnUpdate((float value) => { topTMP.color = new Color(topTMP.color.r, topTMP.color.g, topTMP.color.b, value); }); yield return(new WaitForSeconds(0.75f)); bottomText = Instantiate(bottomTextPrefab); bottomText.transform.SetParent(GameObject.FindGameObjectWithTag("Text Canvas").transform, false); bottomText.GetComponent <TextMeshProUGUI>().text = receivedItems[0].itemName; TextMeshProUGUI bottomTMP = bottomText.GetComponent <TextMeshProUGUI>(); bottomTMP.color = new Color(bottomTMP.color.r, bottomTMP.color.g, bottomTMP.color.b, 0); LeanTween.moveY(bottomText, transform.position.y - 3, 1.5f).setEase(LeanTweenType.easeOutCubic); LeanTween.scale(bottomText, new Vector2(3.5f, 3.5f), 1.5f).setEase(LeanTweenType.easeOutCubic); LeanTween.value(gameObject, 0, 1, 0.5f).setEase(LeanTweenType.easeOutCubic).setOnUpdate((float value) => { bottomTMP.color = new Color(bottomTMP.color.r, bottomTMP.color.g, bottomTMP.color.b, value); }); yield return(new WaitForSeconds(0.75f)); machineKnob.SetState(MachineKnob.State.Displaying); }
protected void Corpse() { LeanTween.alpha(gameObject, 0f, 2f).setOnComplete(() => SimplePool.Despawn(gameObject)); }
// Use this for initialization void Start() { LeanTween.alpha(gameObject, 0, 0.7f).setDelay(Random.Range(0, 2)).setLoopPingPong(-1); }
private void StateMachine() { switch (currentState) { //////////////////////////////////////////////////// case States.Patrol: if (currentState != lastState) { isIdle = false; lastState = currentState; } Patrol(); if (Vector3.Distance(transform.position, playerTransform.position) <= detectionDistance) { currentState = States.Chase; } else if (Vector3.Distance(transform.position, playerTransform.position) <= distanceToAttack) { currentState = States.Attack; } else if (wasHit) { currentState = States.Hit; life--; wasHit = false; } break; //////////////////////////////////////// case States.Chase: if (currentState != lastState) { darkAnimator.SetBool("IsWalking", true); coloredAnimator.SetBool("IsWalking", true); lastState = currentState; isIdle = false; } Chase(); Debug.DrawLine(transform.position, transform.position + transform.right * distanceToAttack); if (Vector3.Distance(transform.position, playerTransform.position) > detectionDistance) { currentState = States.Patrol; } else if (Vector3.Distance(transform.position, playerTransform.position) <= distanceToAttack) { currentState = States.Attack; } else if (wasHit) { currentState = States.Hit; life--; wasHit = false; } break; /////////////////////////////////////// case States.Stunned: if (currentState != lastState) { timeWhenStunned = Time.timeSinceLevelLoad; lastState = currentState; } Stunned(); wasHit = false; if (Time.timeSinceLevelLoad >= timeWhenStunned + maxTimeStunned) { //stunnedMask.transform.localScale = Vector3.zero; currentState = States.Transition; nextState = States.Patrol; life = numOfLives; } break; //////////////////////////////////////////////////// case States.Transition: if (currentState != lastState) { darkAnimator.SetBool("IsWalking", false); coloredAnimator.SetBool("IsWalking", false); if (nextState == States.Stunned) { darkMaterial.SetFloat("Respawn", 0f); LeanTween.alpha(coloredStunnedRenderer.gameObject, 1f, BLINK_TIME).setEaseInCirc(); } else { darkMaterial.SetFloat("Respawn", 1f); LeanTween.alpha(coloredStunnedRenderer.gameObject, 0f, BLINK_TIME).setEaseOutCirc(); } lastState = currentState; } UpdateEffect(); wasHit = false; if (animationTime == 1f || animationTime == 0f) { currentState = nextState; } break; //////////////////////////////////////////////////// case States.Attack: if (currentState != lastState) { darkAnimator.SetBool("IsWalking", false); coloredAnimator.SetBool("IsWalking", false); MainCharacterControls.mainCharacter.WasHit(transform.position); attackTime = Time.timeSinceLevelLoad; lastState = currentState; } if (Time.timeSinceLevelLoad >= attackTime + rechargeTime) { currentState = States.Chase; } else if (wasHit) { currentState = States.Hit; life--; wasHit = false; } break; //////////////////////////////////////////////////// case States.None: break; //////////////////////////////////////////////////// case States.Hit: if (currentState != lastState) { darkAnimator.SetBool("IsWalking", false); darkAnimator.SetTrigger("IsHit"); hitDirection = transform.position - playerTransform.position; hitTime = Time.timeSinceLevelLoad; hitMoveSpeed = hitForce; lastState = currentState; } hitDirection.z = 0f; if (!IsFlying) { hitDirection.y = 0f; } Vector2 minPoint = areaLimits.bounds.min + darkRenderer.bounds.extents; Vector3 maxPoint = areaLimits.bounds.max - darkRenderer.bounds.extents; hitMoveSpeed = Mathf.Max(hitMoveSpeed - hitStopForce * Time.deltaTime, 0f); transform.position += hitDirection * hitMoveSpeed * Time.deltaTime; Vector2 nextPos = new Vector3(Mathf.Clamp(transform.position.x, minPoint.x, maxPoint.x), Mathf.Clamp(transform.position.y, minPoint.y, maxPoint.y), transform.position.z); transform.position = nextPos; if (life == 0 && hitMoveSpeed == 0f) { currentState = States.Transition; nextState = States.Stunned; life = numOfLives; } else if (Time.timeSinceLevelLoad >= hitTime + hitStunTime) { currentState = States.Chase; } break; } }
// Start is called before the first frame update void Start() { LeanTween.alpha(back1.GetComponent <RectTransform>(), 0f, 1f).setDelay(2f); LeanTween.alpha(back2.GetComponent <RectTransform>(), 0f, 1f).setDelay(1.5f); LeanTween.alpha(back3.GetComponent <RectTransform>(), 0f, 1f).setDelay(1f); }
void destroySpear() { animator.SetTrigger("Pop"); LeanTween.alpha(this.gameObject, 0, 0.5f); Destroy(this.gameObject, 6f / 12f); }
private void Start() { spriteRenderer.color = new Color(customColor.r, customColor.g, customColor.b, 0); LeanTween.alpha(this.gameObject, 1, 0.25f); spriteRenderer.sprite = runeSprites[Random.Range(0, runeSprites.Count)]; }
public void OnLoadStart() { LoadObjectsTurn(); LoadNewTip(); LeanTween.alpha(FadeObject, 0, AutomaticTipFadeTime).setEase(AutomaticTipTweenType); }
/// <summary> /// <para>L'opacité du rideau diminue jusqu'à 0, rendu final transparent</para> /// </summary> /// <returns></returns> public void FadeToMin() { LeanTween.alpha(gameObject.GetComponent <RectTransform>(), 0f, 2f); }
private void FadeOutOldTip() { LeanTween.alpha(TipFadeObject, 1, AutomaticTipFadeTime).setEase(AutomaticTipTweenType).setOnComplete(FadeInNewTip); }
void AnimateElementsSeq01() { // animation LeanTween.alpha(superTireSmallLogo, 1f, 0.75f) .setEase(LeanTweenType.easeInOutCubic) .setDelay(0f); LeanTween.delayedCall(0.15f, () => { UIManager.Instance.soundManager.PlaySound("PlaySawLowHighTone"); }); LeanTween.scale(popupBg, new Vector3(1f, 1f, 1f), 0.65f) .setDelay(0.15f) .setOvershoot(0.5f) .setEase(LeanTweenType.easeOutBack); LeanTween.delayedCall(0.95f, () => { UIManager.Instance.soundManager.PlaySound("PlayNoiseMidHighTone"); }); // Scale In Bright Effect LeanTween.scale(raceTrackBrightBg, new Vector3(1f, 1f, 1f), 0.65f) .setDelay(0.75f) .setOvershoot(0.95f) .setEase(LeanTweenType.easeOutBack) .setFromColor(elementShowColor); LeanTween.alpha(raceTrackBg, 1f, 0.85f) .setEase(LeanTweenType.easeOutSine) .setDelay(0.95f); LeanTween.scale(titleText, new Vector3(titleScale.x, titleScale.y, 1f), 0.65f) .setDelay(0.35f) .setEase(LeanTweenType.easeOutBack); LeanTween.scale(congratsBg, new Vector3(1f, 1f, 1f), 0.65f) .setDelay(0.35f) .setEase(LeanTweenType.easeOutBack) .setOnComplete(() => { // Fade Out Bright Effect LeanTween.alpha(raceTrackBrightBg, 0f, 0.75f) .setEase(LeanTweenType.easeOutCubic) .setDelay(0f); }); // show track times LeanTween.delayedCall(1.2f, () => { // all time circle LeanTween.scale(trackRecordCircleBright, new Vector3(1, 1, 1), 0.35f).setDelay(0f).setEase(LeanTweenType.easeOutCubic); LeanTween.alpha(trackRecordCircleBright, 1f, 0.35f) .setEase(LeanTweenType.easeOutCubic) .setDelay(0f); LeanTween.alphaCanvas(trackRecordCircle.GetComponent <CanvasGroup>(), 1f, 0.5f) .setEase(LeanTweenType.easeOutCubic) .setDelay(0.33f); LeanTween.alpha(trackRecordCircleBright, 0f, 0.45f) .setEase(LeanTweenType.easeOutSine) .setDelay(0.45f); // track time circle LeanTween.scale(yourTimeCircleBright, new Vector3(1, 1, 1), 0.35f).setDelay(0f).setEase(LeanTweenType.easeOutCubic); LeanTween.alpha(yourTimeCircleBright, 1f, 0.35f) .setEase(LeanTweenType.easeOutCubic) .setDelay(0f); LeanTween.alphaCanvas(yourTimeCircle.GetComponent <CanvasGroup>(), 1f, 0.5f) .setEase(LeanTweenType.easeOutCubic) .setDelay(0.33f); LeanTween.alpha(yourTimeCircleBright, 0f, 0.45f) .setEase(LeanTweenType.easeOutSine) .setDelay(0.45f) .setOnComplete(AnimateElementsSeq02); }); }
void Start() { // Time.timeScale = 0.25f; LeanTest.timeout = 46f; LeanTest.expected = 59; LeanTween.init(15 + 1200); // 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()); }
public override void durationFinishedProcedure() { StopAllCoroutines(); LeanTween.alpha(this.gameObject, 0, 0.5f).setOnComplete(() => { targetEnemy.removeStatus(this); Destroy(this.gameObject); }); }
protected override void ApplyTween(GameObject go) { var images = go.GetComponentsInChildren <Image>(); for (int i = 0; i < images.Length; i++) { var image = images[i]; if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { case FadeMode.Alpha: Color tempColor = image.color; tempColor.a = targetAlpha; image.color = tempColor; break; case FadeMode.Color: image.color = targetColor; break; } } else { switch (fadeMode) { case FadeMode.Alpha: LeanTween.alpha(image.rectTransform, targetAlpha, duration).setEase(tweenType).setEase(tweenType); break; case FadeMode.Color: LeanTween.color(image.rectTransform, targetColor, duration).setEase(tweenType).setEase(tweenType); break; } } } var texts = go.GetComponentsInChildren <Text>(); for (int i = 0; i < texts.Length; i++) { var text = texts[i]; if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { case FadeMode.Alpha: Color tempColor = text.color; tempColor.a = targetAlpha; text.color = tempColor; break; case FadeMode.Color: text.color = targetColor; break; } } else { switch (fadeMode) { case FadeMode.Alpha: LeanTween.textAlpha(text.rectTransform, targetAlpha, duration).setEase(tweenType); break; case FadeMode.Color: LeanTween.textColor(text.rectTransform, targetColor, duration).setEase(tweenType); break; } } } var textMeshes = go.GetComponentsInChildren <TextMesh>(); for (int i = 0; i < textMeshes.Length; i++) { var textMesh = textMeshes[i]; if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { case FadeMode.Alpha: Color tempColor = textMesh.color; tempColor.a = targetAlpha; textMesh.color = tempColor; break; case FadeMode.Color: textMesh.color = targetColor; break; } } else { switch (fadeMode) { case FadeMode.Alpha: LeanTween.alpha(go, targetAlpha, duration).setEase(tweenType); break; case FadeMode.Color: LeanTween.color(go, targetColor, duration).setEase(tweenType); break; } } } #if UNITY_2018_1_OR_NEWER var tmpros = go.GetComponentsInChildren <TMPro.TMP_Text>(); for (int i = 0; i < tmpros.Length; i++) { var tmpro = tmpros[i]; if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { case FadeMode.Alpha: Color tempColor = tmpro.color; tempColor.a = targetAlpha; tmpro.color = tempColor; break; case FadeMode.Color: tmpro.color = targetColor; break; } } else { switch (fadeMode) { case FadeMode.Alpha: LeanTween.value(tmpro.gameObject, tmpro.color.a, targetAlpha.Value, duration) .setEase(tweenType) .setOnUpdate((float alphaValue) => { Color tempColor = tmpro.color; tempColor.a = alphaValue; tmpro.color = tempColor; }); break; case FadeMode.Color: LeanTween.value(tmpro.gameObject, tmpro.color, targetColor.Value, duration) .setEase(tweenType) .setOnUpdate((Color colorValue) => { tmpro.color = colorValue; }); break; } } } #endif //canvas groups don't support color but we can anim the alpha IN the color var canvasGroups = go.GetComponentsInChildren <CanvasGroup>(); for (int i = 0; i < canvasGroups.Length; i++) { var canvasGroup = canvasGroups[i]; if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { case FadeMode.Alpha: canvasGroup.alpha = targetAlpha.Value; break; case FadeMode.Color: canvasGroup.alpha = targetColor.Value.a; break; } } else { switch (fadeMode) { case FadeMode.Alpha: LeanTween.alphaCanvas(canvasGroup, targetAlpha, duration).setEase(tweenType); break; case FadeMode.Color: LeanTween.alphaCanvas(canvasGroup, targetColor.Value.a, duration).setEase(tweenType); break; } } } }
// Use this for initialization void Start() { LeanTween.alpha(this.gameObject, 0, 0.5f); }
public void HideDangerIndicator() { LeanTween.cancel(fadeInId); fadeOutId = LeanTween.alpha(_sprite.gameObject, 0f, _fadeTime * Time.timeScale).id; }
//LeanTween.addListener //LeanTween.alpha public static LTDescr LeanAlpha(this GameObject gameObject, float to, float time) { return(LeanTween.alpha(gameObject, to, time)); }
private void TweenArrowAlpha(float destinationAlpha) { LeanTween.alpha(leftArrow.rectTransform, destinationAlpha, tweenTime).setEase(easeType); LeanTween.alpha(rightArrow.rectTransform, destinationAlpha, tweenTime).setEase(easeType); }
//LeanTween.alpha (RectTransform) public static LTDescr LeanAlpha(this RectTransform rectTransform, float to, float time) { return(LeanTween.alpha(rectTransform, to, time)); }
public void FadeIn() { LeanTween.alpha(panelRect, 1f, 1f).setEase(LeanTweenType.linear); }
/// <summary> /// Show portrait with the supplied portrait options /// </summary> /// <param name="options"></param> // 显示角色命令 public virtual void Show(PortraitOptions options) { // 清理和检查参数 options = CleanPortraitOptions(options); // 使用Shift功能 // 起点是相对位置 if (options.shiftIntoPlace) { // 复制出来的是GameObject options.fromPosition = Instantiate(options.toPosition) as RectTransform; // 起点在左侧 if (options.offset == PositionOffset.OffsetLeft) { options.fromPosition.anchoredPosition = new Vector2(options.fromPosition.anchoredPosition.x - Mathf.Abs(options.shiftOffset.x), options.fromPosition.anchoredPosition.y - Mathf.Abs(options.shiftOffset.y)); } // 起点在右侧 else if (options.offset == PositionOffset.OffsetRight) { options.fromPosition.anchoredPosition = new Vector2(options.fromPosition.anchoredPosition.x + Mathf.Abs(options.shiftOffset.x), options.fromPosition.anchoredPosition.y + Mathf.Abs(options.shiftOffset.y)); } else { // 直接使用Offset // 进行偏移 options.fromPosition.anchoredPosition = new Vector2(options.fromPosition.anchoredPosition.x, options.fromPosition.anchoredPosition.y); } } // 设置角色Portrait的朝向 SetupPortrait(options); // 防止0 // LeanTween doesn't handle 0 duration properly float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon; // 旧形象 // 消失效果 // Fade out a duplicate of the existing portrait image if (options.character.State.portraitImage != null && options.character.State.portraitImage.overrideSprite != null) { // 复制出当前Portrait // 播放消失效果 // portraitImage是Image类型 GameObject tempGO = GameObject.Instantiate(options.character.State.portraitImage.gameObject); // 放置在当前Portrait前 tempGO.transform.SetParent(options.character.State.portraitImage.transform, false); tempGO.transform.localPosition = Vector3.zero; tempGO.transform.localScale = options.character.State.position.localScale; // 设置形象图片 Image tempImage = tempGO.GetComponent <Image>(); tempImage.overrideSprite = options.character.State.portraitImage.overrideSprite; tempImage.preserveAspect = true; tempImage.color = options.character.State.portraitImage.color; // alpha消失效果 LeanTween. alpha(tempImage.rectTransform, 0f, duration). setEase(stage.FadeEaseType). setOnComplete( () => { Destroy(tempGO); } ). setRecursive(false); } // 渐显新的形象 // Fade in the new sprite image if (options.character.State.portraitImage.overrideSprite != options.portrait || options.character.State.portraitImage.color.a < 1f) { options.character.State.portraitImage.overrideSprite = 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). setRecursive(false); } // 移动角色形象 // 到目标点 DoMoveTween(options); // 立即执行onComplete // 还是fade结束后,调用 // PortraitOptions: 各种参数 FinishCommand(options); // 添加角色到 // CharactersOnStage列表 if (!stage.CharactersOnStage.Contains(options.character)) { stage.CharactersOnStage.Add(options.character); } // 更新角色状态 // Update character state after showing options.character.State.onScreen = true; options.character.State.display = DisplayType.Show; options.character.State.portrait = options.portrait; options.character.State.facing = options.facing; options.character.State.position = options.toPosition; }