public static scale ( GameObject gameObject, Vector3 to, float time ) : LTDescr, | ||
gameObject | GameObject | |
to | Vector3 | |
time | float | |
return | LTDescr, |
public void TutorialAnimation(GameObject gameObject) { LeanTween.scale(gameObject, Vector3.one, 0.25f).setEaseOutBounce(); }
private void initNextSequence() { if (_currSequence >= _maxSequence) { FinishElementAction(); return; } _currSequence++; switch (_currSequence) { case 0: { // Aparece Mochila rappi LeanTween.scale(bag, Vector3.one * 1.1f * scaleBag, timeScale).setOnComplete(() => { LeanTween.scale(bag, Vector3.one * scaleBag, .1f); LeanTween.delayedCall(timeToNextAction[_currSequence], () => { initNextSequence(); }); }); break; } case 1: { int count = containers.Length; // Se elevan los contenedores for (int i = 0; i < containers.Length; i++) { LeanTween.moveLocal(containers[i], new Vector3(containers[i].transform.localPosition.x, maxheightContainers, containers[i].transform.localPosition.z), timeMovContainer).setEase(LeanTweenType.easeOutSine).setOnComplete(() => { count--; if (count <= 0) { LeanTween.delayedCall(timeToNextAction[_currSequence], () => { initNextSequence(); }); } }); } break; } case 2: { // Mochila rappi ingresa en el contenedor central y desaparece PlaySound(clipHideBag); LeanTween.move(bag, _splineBag, timeHideBag).setEase(LeanTweenType.easeInSine).setOnComplete(() => { LeanTween.delayedCall(timeToNextAction[_currSequence], () => { initNextSequence(); }); }); LeanTween.scale(bag, Vector3.zero, .5f). setOnUpdate((float f) => { matBag.SetFloat("_Transparency", f); }). setDelay(timeHideBag / 3); break; } case 3: { int count = containers.Length; // Bajan los contenedores a su posicion inicial. for (int i = 0; i < containers.Length; i++) { LeanTween.moveLocal(containers[i], new Vector3(containers[i].transform.localPosition.x, initheightContainers, containers[i].transform.localPosition.z), timeMovContainer).setEase(LeanTweenType.easeOutSine).setOnComplete(() => { count--; if (count <= 0) { LeanTween.delayedCall(timeToNextAction[_currSequence], () => { FinishElementAction(); }); } }); } break; } } }
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()); }
private void Start() { this.originalScale = this.transform.localScale; //StartCoroutine(ScaleAnimation()); LeanTween.scale(this.gameObject, this.scaleTo, this.scaleTime).setLoopPingPong().setEaseInOutCirc(); }
public void CloseLeaderboard() { //ClearContainer int l = LeaderboardElementGroup.transform.childCount; if (LeaderboardElementGroup.transform.GetChild(0).name == "LoginPleaseFacebook(Clone)") { var e = LeaderboardElementGroup.transform.GetChild(0); LeanTween.moveX(e.gameObject, 1000, 0.7f).setDelay(0.1f).setEaseInOutCubic().setOnComplete(() => { Destroy(e.gameObject); }); } else { for (int i = 0; i < l; i++) { var displacer = LeaderboardElementGroup.transform.GetChild(i).GetChild(0); //LeanTween.moveX(displacer.gameObject, -1000, 0.7f).setDelay(0.1f * i).setEaseInOutCubic().setOnComplete(() => { LeanTween.moveX(displacer.gameObject, 1000, 0.7f).setDelay(0.1f * (l - i)).setEaseInOutCubic().setOnComplete(() => { Destroy(displacer.transform.parent.gameObject); }); } } LeanTween.delayedCall(0.7f, () => { AnimatableLeader.Clear(); //Leaderboard Button Group RectTransform leaderboardButtonsRect = LeaderboardButtonGroup.GetComponent <RectTransform>(); LeanTween.value(leaderboardButtonsRect.anchorMax.x, 1.2f, 0.7f).setEaseOutCubic().setOnUpdate((float f) => { leaderboardButtonsRect.anchorMax = new Vector2(f, 1f); }); //Leaderboard Header LeanTween.value(LeaderboardHeader.transform.localPosition.y, 570, 0.7f).setEaseOutCubic().setOnUpdate((float f) => { LeaderboardHeader.transform.localPosition = new Vector3(0, f, 0); }).setOnComplete(() => { LeaderboardGroup.SetActive(false); }); //Leaderboard TopBox LeanTween.value(TopBox.localPosition.x, -1650, 0.7f).setEaseOutCubic().setOnUpdate((float f) => { TopBox.localPosition = new Vector3(f, TopBox.localPosition.y, 0); }); //Leaderboard BottomBox LeanTween.value(BottomBox.localPosition.x, 1650, 0.7f).setEaseOutCubic().setDelay(0.15f).setOnUpdate((float f) => { BottomBox.localPosition = new Vector3(f, BottomBox.localPosition.y, 0); }); //Leaderboard LeftBox LeanTween.value(LeftBox.localPosition.y, -920, 0.7f).setEaseOutCubic().setDelay(0.4f).setOnUpdate((float f) => { LeftBox.localPosition = new Vector3(LeftBox.localPosition.x, f, 0); }); //Leaderboard RightBox LeanTween.value(RightBox.localPosition.y, 920, 0.7f).setEaseOutCubic().setDelay(0.45f).setOnUpdate((float f) => { RightBox.localPosition = new Vector3(RightBox.localPosition.x, f, 0); }).setOnComplete(() => { LeaderboardButtonGroup.SetActive(false); }); //Loading Image LeanTween.scale(LoadingImage.gameObject, new Vector3(0, 0, 1), 0.7f).setEaseInOutElastic().setOnComplete(() => { LoadingImage.gameObject.SetActive(false); }); }); }
public void PanelIdle() { LeanTween.scale(panelfirst, new Vector3(1f, 1f, 1f), 0.1f); LeanTween.scale(panelsecond, new Vector3(1f, 1f, 1f), 0.1f); }
void Start() { LeanTween.scale(gameObject, transform.localScale * scaleChange, scaleTime).setEaseInOutSine().setLoopPingPong(); LeanTween.rotateAround(gameObject, Vector3.forward, rotateAngle, rotateTime).setLoopClamp(); }
private void Start() { LeanTween.scale(this.gameObject, Vector3.one, 0.6f).setEaseInOutSine(); Invoke((m) => this.gameObject.SetActive(false), TimeSpan.FromSeconds(5)); }
public void RunSequence(bool dontStartYet = false) { if (Animating) { return; } if (dontStartYet) { m_createdTweens = new List <LTDescr>(); } else if (HasDefaultState) { foreach (var tween in m_createdTweens) { tween.toggle = true; } Animating = true; return; } float totalDelay = 0f; float delayOfPrevSequence = 0f; bool inEditor = !Application.isPlaying; //seems to result in smoother previews if (inEditor) { totalDelay = 1.5f; } //Record default state before any modifications foreach (var step in Elements) { if (step.Target == null) { Debug.LogError("Step has no target object"); return; } var xform = step.Target.GetComponent <RectTransform>(); if (xform == null) { Debug.LogError(step.Target.name + " has no RectTransform"); return; } foreach (var action in step.Actions) { SaveActionOriginalState(step, action, xform); } } HasDefaultState = true; Animating = true; //Go through all sequence steps foreach (var step in Elements) { if (step.Target == null) { continue; } RectTransform xform = step.Target.GetComponent <RectTransform>(); float delayForThisSequence; if (step.LinkToPrevious) { delayForThisSequence = step.Delay + delayOfPrevSequence; } else { delayForThisSequence = step.Delay + totalDelay; delayOfPrevSequence = delayForThisSequence; } //Go through actions and add tweens foreach (var action in step.Actions) { LTDescr descr; switch (action.Type) { case ActionType.Move: { var origpos = xform.anchoredPosition3D; xform.anchoredPosition3D = xform.anchoredPosition3D + action.Vector; descr = LeanTween.move(xform, origpos, step.Duration); break; } case ActionType.RotateZ: { if (action.Direction == Direction.From) { Vector3 origRot = xform.localRotation.eulerAngles; xform.localEulerAngles = xform.localEulerAngles.WithZ(xform.localEulerAngles.z - action.Float); descr = LeanTween.rotateAroundLocal(step.Target, new Vector3(0, 0, 1), action.Float, step.Duration); } else { descr = LeanTween.rotateAroundLocal(step.Target, new Vector3(0, 0, 1), action.Float, step.Duration); } } break; case ActionType.Scale: { if (action.Direction == Direction.From) { Vector3 tgtScale = xform.localScale; xform.localScale = action.Vector; descr = LeanTween.scale(step.Target, tgtScale, step.Duration); } else { descr = LeanTween.scale(step.Target, action.Vector, step.Duration); } break; } case ActionType.Fly: { Vector3 startPos = xform.anchoredPosition3D; float to = action.Float; switch (action.TravelDirection) { case TravelDirection.Left: if (action.Direction == Direction.From) { to = xform.anchoredPosition3D.x; startPos = new Vector3(startPos.x - action.Float, startPos.y, startPos.z); xform.anchoredPosition3D = startPos; descr = LeanTween.moveX(xform, to, step.Duration); } else { //passing correct to value to moveX is critical even if SetupMoveTo overrides it. //Leantween does a diff calculation with the to value before calling onStart. descr = LeanTween.moveX(xform, -action.Float, step.Duration); SetupMoveTo(descr, new Vector2(-action.Float, 0f)); } break; case TravelDirection.Right: if (action.Direction == Direction.From) { to = xform.anchoredPosition3D.x; startPos = new Vector3(startPos.x + action.Float, startPos.y, startPos.z); xform.anchoredPosition3D = startPos; descr = LeanTween.moveX(xform, to, step.Duration); } else { descr = LeanTween.moveX(xform, to, step.Duration); SetupMoveTo(descr, new Vector2(action.Float, 0f)); } break; case TravelDirection.Up: if (action.Direction == Direction.From) { to = xform.anchoredPosition3D.y; startPos = new Vector3(startPos.x, startPos.y + action.Float, startPos.z); xform.anchoredPosition3D = startPos; descr = LeanTween.moveY(xform, to, step.Duration); } else { descr = LeanTween.moveY(xform, to, step.Duration); SetupMoveTo(descr, new Vector2(0, action.Float)); } break; default: case TravelDirection.Down: if (action.Direction == Direction.From) { to = xform.anchoredPosition3D.y; startPos = new Vector3(startPos.x, startPos.y - action.Float, startPos.z); xform.anchoredPosition3D = startPos; descr = LeanTween.moveY(xform, to, step.Duration); } else { descr = LeanTween.moveY(xform, -action.Float, step.Duration); SetupMoveTo(descr, new Vector2(0, -action.Float)); } break; } break; } case ActionType.Fade: var cg = step.Target.GetComponent <CanvasGroup>(); var graphic = step.Target.GetComponent <Graphic>(); if (cg != null) { float tgtval; if (action.Direction == Direction.From) { float srcval = action.Float; tgtval = cg.alpha; cg.alpha = srcval; } else { tgtval = action.Float; } descr = LeanTween.alphaCanvas(cg, tgtval, step.Duration); } else //if (graphic != null) { float tgtval; if (action.Direction == Direction.From) { float srcval = action.Float; tgtval = graphic.color.a; graphic.color = graphic.color.WithA(srcval); } else { tgtval = action.Float; } descr = LeanTween.alpha(xform, tgtval, step.Duration); } break; case ActionType.Show: { descr = LeanTween.delayedCall(1f, () => step.Target.SetActive(true)); descr.time = step.Duration; //todo check break; } case ActionType.Hide: { descr = LeanTween.delayedCall(1f, () => step.Target.SetActive(false)); descr.time = step.Duration; //todo check break; } case ActionType.Event: { descr = LeanTween.delayedCall(1f, action.Event.Invoke); descr.time = step.Duration; //todo check break; } case ActionType.Shake: { Vector3 magnitude = action.Vector; float frequency = action.Float; descr = LeanTween.value(1, 0f, step.Duration) .setOnStart(() => { action.LocalPosAtStart = xform.anchoredPosition3D; }) .setOnUpdate((float v) => { Vector3 origPos = action.LocalPosAtStart; float decay = 1f; //1f - v; float seed = Time.time * frequency; float p = Mathf.PerlinNoise(seed, 0f) - 0.5f; float py = Mathf.PerlinNoise(0f, seed) - 0.5f; var shakePosition = new Vector3( p * magnitude.x * decay, py * magnitude.y * decay, 0f); xform.anchoredPosition3D = Vector3.LerpUnclamped(origPos, origPos + shakePosition, v); }).setOnComplete(() => { xform.anchoredPosition3D = action.LocalPosAtStart; }); break; } default: throw new NotImplementedException(); } descr.setDelay(delayForThisSequence); if (action.Easing == LeanTweenType.animationCurve) { descr.setEase(action.Curve); } else { descr.setEase(action.Easing); } totalDelay = Math.Max(totalDelay, descr.delay + descr.time); //must for editor preview if (inEditor) { //descr.setIgnoreTimeScale(true); descr.setUseEstimatedTime(true); descr.setUseFrames(true); } if (dontStartYet) { descr.toggle = false; m_createdTweens.Add(descr); Animating = false; } } } //add one more call to trigger the end //Debug.Log("oncomplete will fire at " + totalDelay); LeanTween.delayedCall(totalDelay, OnCompleteTheWholeThing); }
public void OnPointerEnter(PointerEventData eventData) { m_image.color = m_negativColor; m_text.color = m_negativColorText; LeanTween.scale(gameObject, m_baseScale * m_sizeOnHover, m_time).setEase(m_animationCurve); }
public void OnPointerExit(PointerEventData eventData) { m_image.color = m_baseColor; m_text.color = m_baseColorText; LeanTween.scale(gameObject, m_baseScale, m_time).setEase(m_animationCurve); }
public void SetHealthPercent(float percent) { percent = Mathf.Clamp(percent, 0, 1); LeanTween.scale(HealthBarTransform, new Vector3(percent, 1), .5f); }
void Update() { LeanTween.dtManual = Time.deltaTime; /*if (Input.GetKeyDown(KeyCode.Q)) * { * //LeanTween.scale(this.gameObject, Vector3.one*3f, 1.0f).setEase(LeanTweenType.easeSpring).setUseManualTime(true); * //print("scale punch time independent!"); * * LeanTween.moveLocalX(gameObject, 5, 1).setOnComplete( () => { * Debug.Log("on complete move local X"); * }).setOnCompleteOnStart(true); * * GameObject light = GameObject.Find("DirectionalLight"); * Light lt = light.GetComponent<Light>(); * * LeanTween.value(lt.gameObject, lt.intensity, 0.0f, 1.5f) * .setEase(LeanTweenType.linear) * .setLoopPingPong() * .setRepeat(-1) * .setOnUpdate((float val)=>{ * * lt.intensity = val; * }); * }*/ if (Input.GetKeyDown(KeyCode.S)) { print("scale punch!"); tweenStatically(this.gameObject); LeanTween.scale(this.gameObject, new Vector3(1.15f, 1.15f, 1.15f), 0.6f); LeanTween.rotateAround(this.gameObject, Vector3.forward, -360f, 0.3f).setOnComplete(() => { LeanTween.rotateAround(this.gameObject, Vector3.forward, -360f, 0.4f).setOnComplete(() => { LeanTween.scale(this.gameObject, new Vector3(1f, 1f, 1f), 0.1f); LeanTween.value(this.gameObject, (v) => { }, 0, 1, 0.3f).setDelay(1); }); }); } if (Input.GetKeyDown(KeyCode.T)) { Vector3[] pts = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f) }; descr = LeanTween.move(gameObject, pts, 15f).setOrientToPath(true).setDirection(1f).setOnComplete(() => { Debug.Log("move path finished"); }); } if (Input.GetKeyDown(KeyCode.Y)) // Reverse the move path { descr.setDirection(-descr.direction); } if (Input.GetKeyDown(KeyCode.R)) { // LeanTween.rotate(this.gameObject, Vector3.one, 1.0f).setEase(LeanTweenType.punch); LeanTween.rotateAroundLocal(this.gameObject, this.transform.forward, -80f, 5.0f).setPoint(new Vector3(1.25f, 0f, 0f)); print("rotate punch!"); } if (Input.GetKeyDown(KeyCode.M)) { // LeanTween.move(this.gameObject, new Vector3(0f,0f,1f), 1.0f).setEase(LeanTweenType.punch); print("move punch!"); Time.timeScale = 0.25f; float start = Time.realtimeSinceStartup; LeanTween.moveX(this.gameObject, 1f, 1f).setOnComplete(destroyOnComp).setOnCompleteParam(this.gameObject).setOnComplete(() => { float end = Time.realtimeSinceStartup; float diff = end - start; Debug.Log("start:" + start + " end:" + end + " diff:" + diff + " x:" + this.gameObject.transform.position.x); }).setEase(LeanTweenType.easeInBack).setOvershoot(overShootValue).setPeriod(0.3f); } if (Input.GetKeyDown(KeyCode.C)) { LeanTween.color(this.gameObject, new Color(1f, 0f, 0f, 0.5f), 1f); Color to = new Color(Random.Range(0f, 1f), 0f, Random.Range(0f, 1f), 0.0f); GameObject l = GameObject.Find("LCharacter"); LeanTween.color(l, to, 4.0f).setLoopPingPong(1).setEase(LeanTweenType.easeOutBounce); } if (Input.GetKeyDown(KeyCode.E)) { LeanTween.delayedCall(gameObject, 0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true).setOnCompleteParam("hi"); } if (Input.GetKeyDown(KeyCode.V)) { LeanTween.value(gameObject, updateColor, new Color(1.0f, 0.0f, 0.0f, 1.0f), Color.blue, 4.0f);//.setRepeat(2).setLoopPingPong().setEase(LeanTweenType.easeOutBounce); } if (Input.GetKeyDown(KeyCode.P)) { LeanTween.delayedCall(0.05f, enterMiniGameStart).setOnCompleteParam(new object[] { "" + 5 }); } if (Input.GetKeyDown(KeyCode.U)) { #if !UNITY_FLASH LeanTween.value(gameObject, (Vector2 val) => { // Debug.Log("tweening vec2 val:"+val); transform.position = new Vector3(val.x, transform.position.y, transform.position.z); }, new Vector2(0f, 0f), new Vector2(5f, 100f), 1f).setEase(LeanTweenType.easeOutBounce); GameObject l = GameObject.Find("LCharacter"); Debug.Log("x:" + l.transform.position.x + " y:" + l.transform.position.y); LeanTween.value(l, new Vector2(l.transform.position.x, l.transform.position.y), new Vector2(l.transform.position.x, l.transform.position.y + 5), 1f).setOnUpdate( (Vector2 val) => { Debug.Log("tweening vec2 val:" + val); l.transform.position = new Vector3(val.x, val.y, transform.position.z); } ); #endif } }
public void OnEnable() { transform.localScale = new Vector3(0, 0, 0); LeanTween.scale(gameObject, new Vector3(1, 1, 1), 0.3f).setDelay(0.1f).setOnComplete(OnComplete); }
void Start() { // Time.timeScale = 1f/4f; // *********** Main Window ********** // Scale the whole window in mainWindow.localScale = Vector3.zero; LeanTween.scale(mainWindow, new Vector3(1f, 1f, 1f), 0.6f).setEase(LeanTweenType.easeOutBack); LeanTween.alphaCanvas(mainWindow.GetComponent <CanvasGroup>(), 0f, 1f).setDelay(2f).setLoopPingPong().setRepeat(2); // Fade the main paragraph in while moving upwards mainParagraphText.anchoredPosition3D += new Vector3(0f, -10f, 0f); LeanTween.textAlpha(mainParagraphText, 0f, 0.6f).setFrom(0f).setDelay(0f); LeanTween.textAlpha(mainParagraphText, 1f, 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f); LeanTween.move(mainParagraphText, mainParagraphText.anchoredPosition3D + new Vector3(0f, 10f, 0f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f); // Flash text to purple and back LeanTween.textColor(mainTitleText, new Color(133f / 255f, 145f / 255f, 223f / 255f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f).setLoopPingPong().setRepeat(-1); // Fade button in LeanTween.textAlpha(mainButton2, 1f, 2f).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad); LeanTween.alpha(mainButton2, 1f, 2f).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad); // Pop size of button LeanTween.size(mainButton1, mainButton1.sizeDelta * 1.1f, 0.5f).setDelay(3f).setEaseInOutCirc().setRepeat(6).setLoopPingPong(); // *********** Pause Button ********** // Drop pause button in pauseWindow.anchoredPosition3D += new Vector3(0f, 200f, 0f); LeanTween.moveY(pauseWindow, pauseWindow.anchoredPosition3D.y + -200f, 0.6f).setEase(LeanTweenType.easeOutSine).setDelay(0.6f); // Punch Pause Symbol RectTransform pauseText = pauseWindow.Find("PauseText").GetComponent <RectTransform>(); LeanTween.moveZ(pauseText, pauseText.anchoredPosition3D.z - 80f, 1.5f).setEase(LeanTweenType.punch).setDelay(2.0f); // Rotate rings around in opposite directions LeanTween.rotateAroundLocal(pauseRing1, Vector3.forward, 360f, 12f).setRepeat(-1); LeanTween.rotateAroundLocal(pauseRing2, Vector3.forward, -360f, 22f).setRepeat(-1); // *********** Chat Window ********** // Flip the chat window in chatWindow.RotateAround(chatWindow.position, Vector3.up, -180f); LeanTween.rotateAround(chatWindow, Vector3.up, 180f, 2f).setEase(LeanTweenType.easeOutElastic).setDelay(1.2f); // Play a series of sprites on the window on repeat endlessly LeanTween.play(chatRect, chatSprites).setLoopPingPong(); // Animate the bar up and down while changing the color to red-ish LeanTween.color(chatBar2, new Color(248f / 255f, 67f / 255f, 108f / 255f, 0.5f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong().setDelay(1.2f); LeanTween.scale(chatBar2, new Vector2(1f, 0.7f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong(); // Write in paragraph text string origText = chatText.text; chatText.text = ""; LeanTween.value(gameObject, 0, (float)origText.Length, 6f).setEase(LeanTweenType.easeOutQuad).setOnUpdate((float val) => { chatText.text = origText.Substring(0, Mathf.RoundToInt(val)); }).setLoopClamp().setDelay(2.0f); // Raw Image LeanTween.alpha(rawImageRect, 0f, 1f).setLoopPingPong(); }
private void Start() { LeanTween.scale(botStartBtn.gameObject, new Vector3(1.7f, 1.7f, 1.7f), 0.5f).setEase(LeanTweenType.easeOutBounce).setOnComplete(() => { ScaleBack(); }); }
// Called when an object enters the collider of another object // Set the target object as the trigger void OnTriggerEnter2D(Collider2D other) { // if the current scene is Learn Spelling if (Application.loadedLevelName == "4. Learn Spelling") { // if the collided objects are the same letter // i.e. if the movable letter that entered matches the target letter if (other.name == gameObject.name) { Debug.Log("Collision on " + other.name); // change color of target letter to match that of movable letter gameObject.GetComponent <SpriteRenderer> ().color = other.GetComponent <SpriteRenderer> ().color; Color color = gameObject.renderer.material.color; color.a = 1.0f; gameObject.renderer.material.color = color; // destroy movable letter Debug.Log("Destroyed draggable letter " + other.gameObject.name); Destroy(other.gameObject); // disable collisions for target letter // so all other movable letters can no longer collide with this letter Debug.Log("Disabled collisions for " + gameObject.name); Destroy(gameObject.GetComponent <CollisionManager>()); // pulse target letter once LeanTween.scale(gameObject, new Vector3(WordCreation.letterScale * 1.2f, WordCreation.letterScale * 1.2f, 1), .6f); LeanTween.scale(gameObject, new Vector3(WordCreation.letterScale, WordCreation.letterScale, 1), .5f).setDelay(.4f); // check if user has completed word if (CheckCompletedWord()) { // sound out the word GameObject[] tar = GameObject.FindGameObjectsWithTag("TargetLetter"); GameObject audioManager = GameObject.Find("AudioManager"); audioManager.GetComponent <AudioManager>().SpellOutWord(tar); // play celebratory animation LearnSpellingDirector.CelebratoryAnimation((tar.Length + 1.5f) * AudioManager.clipLength); // add word to completedWord list ProgressManager.AddCompletedWord(ProgressManager.currentWord); } } } // if the current scene is Spelling Game if (Application.loadedLevelName == "5. Spelling Game") { Debug.Log("Collision on " + other.name); // disable touch gestures for letter other.gameObject.GetComponent <GestureManager>().DisableGestures(other.gameObject); // stop pulsing letter other.gameObject.GetComponent <PulseBehavior>().StopPulsing(other.gameObject); // move letter to center of target blank // z-position of letter = -1, so letter is in front of the blank (z-position of blank = 0) other.gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -1); // change color of letter to indicate collision succesfully occurred other.gameObject.GetComponent <SpriteRenderer>().color = Color.blue; // pulse letter once LeanTween.scale(other.gameObject, new Vector3(WordCreation.letterScale * 1.25f, WordCreation.letterScale * 1.25f, 1), .3f); LeanTween.scale(other.gameObject, new Vector3(WordCreation.letterScale, WordCreation.letterScale, 1), .3f).setDelay(.2f); // disable collisions for target blank // so no other movable letters can collide with this blank anymore Debug.Log("Disabled collisions for Blank " + gameObject.name); Destroy(gameObject.GetComponent <CollisionManager>()); // if all letters have been dragged to a blank if (CheckCompletedTargets("MovableLetter")) { // if the user spelled the word correctly if (CheckCorrectSpelling("TargetBlank")) { // find all movable letters GameObject[] mov = GameObject.FindGameObjectsWithTag("MovableLetter"); // disable touch gestures for sound & hint buttons GameObject.Find("SoundButton").GetComponent <GestureManager>().DisableGestures(GameObject.Find("SoundButton")); GameObject.Find("HintButton").GetComponent <GestureManager>().DisableGestures(GameObject.Find("HintButton")); // mark all correct letters by changing their colors MarkCorrectLetters(0f); // sound out the word SpellingGameDirector.SpellOutWord(); // play celebratory animation SpellingGameDirector.CelebratoryAnimation((mov.Length + 1.5f) * AudioManager.clipLength); // add word to completedWord list ProgressManager.AddCompletedWord(ProgressManager.currentWord); } // if user spelled word incorrectly if (!CheckCorrectSpelling("TargetBlank")) { // play try again animation SpellingGameDirector.TryAgainAnimation(); // mark the correct letters by changing their color MarkCorrectLetters(1f); // move incorrect letters back to original position ResetIncorrectLetters(1f); // play word's sound GameObject.FindGameObjectWithTag("WordObject").audio.PlayDelayed(1f); // flash hint button to call attention to it FlashHintButton(2f); } } } // if current scene is Sound Game if (Application.loadedLevelName == "6. Sound Game") { Debug.Log("Collision on " + other.name); // disable touch gestures for sound blank other.gameObject.GetComponent <GestureManager> ().DisableGestures(other.gameObject); // stop pulsing sound blank other.gameObject.GetComponent <PulseBehavior> ().StopPulsing(other.gameObject); // place sound blank at opening of jar other.gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + 2.2f, 1); // pulse sound blank once LeanTween.scale(other.gameObject, new Vector3(.4f, .4f, 1), .3f); LeanTween.scale(other.gameObject, new Vector3(.3f, .3f, 1), .3f).setDelay(.2f); // change color of jar to match color of sound blank // to indicate successful collision Color color = other.gameObject.GetComponent <SpriteRenderer>().color; Vector2 posn = gameObject.transform.position; Collider2D[] jar = Physics2D.OverlapCircleAll(posn, .1f, 1, 1.5f, 1.5f); LeanTween.color(jar[0].gameObject, color, .01f); // disable collisions for target letter Debug.Log("Disabled collisions for Letter " + gameObject.name); Destroy(gameObject.GetComponent <CollisionManager> ()); // if all sound blanks have been dragged onto a jar if (CheckCompletedTargets("MovableBlank")) { // if user dragged all sound blanks to their correct corresponding letters if (CheckCorrectSpelling("TargetLetter")) { // find all sound blanks GameObject[] mov = GameObject.FindGameObjectsWithTag("MovableBlank"); // disable touch gestures for sound + hint buttons GameObject.Find("SoundButton").GetComponent <GestureManager> ().DisableGestures(GameObject.Find("SoundButton")); GameObject.Find("HintButton").GetComponent <GestureManager> ().DisableGestures(GameObject.Find("HintButton")); // reset correct sound blanks back to original size MarkCorrectSounds(0f); // sound out word GameObject[] tar = GameObject.FindGameObjectsWithTag("TargetLetter"); GameObject audioManager = GameObject.Find("AudioManager"); audioManager.GetComponent <AudioManager>().SpellOutWord(tar); // play celebratory animation SoundGameDirector.CelebratoryAnimation((mov.Length + 1.5f) * AudioManager.clipLength); // add completed word to completedWord list ProgressManager.AddCompletedWord(ProgressManager.currentWord); } // if user did not drag all sound blanks to correct letter if (!CheckCorrectSpelling("TargetLetter")) { // play try again animation SoundGameDirector.TryAgainAnimation(); // reset correct sound blanks back to original size MarkCorrectSounds(1f); // move incorrect sound blanks back to original position ResetIncorrectSounds(1f); // play word's sound GameObject.FindGameObjectWithTag("WordObject").audio.PlayDelayed(1f); // flash hint button to call attention to it FlashHintButton(2f); } } } }
void ScaleBack() { LeanTween.scale(botStartBtn.gameObject, new Vector3(1, 1, 1), 0.5f).setEase(LeanTweenType.easeInBounce).setOnComplete(() => { Start(); }); }
public void PanelFirstFadeIn() { LeanTween.scale(panelfirst, new Vector3(0f, 0f, 0f), 0.1f); LeanTween.scale(panelsecond, new Vector3(1f, 1f, 1f), 0.1f); }
public void OnUIInstantiated(FageUIPopupMem mem) { LeanTween.move(imageReady.rectTransform, imageGo.rectTransform.anchoredPosition, 0.5f).setEase(LeanTweenType.easeOutBounce).setOnComplete(OnReadyComplete); LeanTween.scale(imageReady.rectTransform, new Vector3(1f, 1f, 1f), 0.3f).setEase(LeanTweenType.easeOutCirc); }
public void Scale() { _tweenObject = LeanTween.scale(gameObject, to, animationDuration); }
private void OnReadyComplete() { LeanTween.scale(imageReady.rectTransform, new Vector3(0f, 0f, 1f), 0.3f).setEase(LeanTweenType.easeInCubic).setDelay(1f); LeanTween.scale(imageGo.rectTransform, Vector3.one, 0.5f).setEase(LeanTweenType.easeOutElastic).setDelay(1f).setOnComplete(OnGoComplete); }
void Start() { LeanTween.scale(GameObject, new Vector2(1f, 1f), 0).setOnComplete(OnComplete); }
private void OnGoComplete() { LeanTween.scale(imageGo.rectTransform, new Vector3(0f, 0f, 1f), 0.3f).setEase(LeanTweenType.easeInBack).setDelay(0.5f).setOnComplete(OnStandbyComplete); }
public void LeaderboardStopLoading() { LeanTween.scale(LoadingImage.gameObject, new Vector3(0, 0, 1), 0.7f).setEaseInOutElastic().setOnComplete(() => { LoadingImage.gameObject.SetActive(false); }); }
public void OnMouseEnter() { //Scales objects to indicate you can click on them LeanTween.scale(character, new Vector3(0.8f, .8f, .8f), .03f); }
void OnEnable() { gameObject.transform.localScale = initialScale; LeanTween.scale(gameObject, finalScale, scaleTime).setEase(easeType); }
public void OnMouseExit() { //Sets objects back to their original size LeanTween.scale(character, new Vector3(0.7f, 0.7f, 0.7f), .01f); }
// Use this for initialization void Start() { rb = gameObject.GetComponent <Rigidbody>(); LeanTween.scale(gameObject, new Vector3(.2f, .2f, .2f), .5f).setLoopPingPong().setEaseInExpo(); }
public void InternetCheckPanel(GameObject gameObject, float time) { LeanTween.scale(gameObject, Vector3.one, time).setEaseOutBounce(); }