public static textAlpha ( |
||
rectTransform | ||
to | float | |
time | float | |
return | LTDescr, |
private void OnLogin() { LeanTween.delayedCall(1.2f, StartGame); LeanTween.alpha(studioLogo.rectTransform, 0, 0.4f); LeanTween.textAlpha(studioTitle.rectTransform, 0, 0.4f).delay = 0.4f; studioAnim.Play("STUDIO_OUT"); }
/// <summary> /// /// </summary> /// <param name="comboCount"></param> public void ShowComboResult(int comboCount) { //TODO: localization _comboText.text = "+ " + comboCount.ToString(); _comboText.color = _comboResultColor; _comboText.fontSize = _comboFontSize_result; _comboText.transform.rotation = Quaternion.Euler(Vector3.forward * 25f); if (!_comboText.transform.parent.gameObject.activeInHierarchy) { _comboText.transform.parent.gameObject.SetActive(true); } //Bg if (_comboBg.gameObject.activeSelf) { _comboBg.gameObject.SetActive(false); } if (!_comboTotalBg.gameObject.activeSelf) { _comboTotalBg.gameObject.SetActive(true); } LeanTween.cancel(_comboTotalBg.gameObject); LeanTween.alpha(_comboTotalBg.gameObject, .01f, _comboFeedbackTime); if (!_comboText.gameObject.activeInHierarchy) { _comboText.gameObject.SetActive(true); } LeanTween.cancel(_comboText.transform.parent.gameObject); LeanTween.cancel(_comboText.gameObject); LeanTween.moveLocalY(_comboText.transform.parent.gameObject, _comboOffset, _comboFeedbackTime); _comboText.transform.parent.localScale = Vector3.one; LeanTween.scale(_comboText.transform.parent.gameObject, Vector3.one * 1.2f, _comboFeedbackTime * 0.5f); LeanTween.textAlpha(_comboText.rectTransform, .01f, _comboFeedbackTime).setOnComplete(() => { _comboText.transform.parent.gameObject.SetActive(false); }); }
void Start() { //将字体放大到指定倍数 LeanTween.scale(rect, originScale * scaleTo, scaleTime).setOnComplete( //Scale完成后执行缩小,移动 () => { LeanTween.scale(rect, originScale, scaleTime).setOnComplete( () => { LeanTween.move(rect, rect.anchoredPosition + moveBy, 0.2f).setOnComplete( //移动完成后,淡出 () => { LeanTween.textAlpha(rect, 0f, fadeOutTime).setOnComplete( //淡出后自动销毁 () => { if (destroyOnComplete) { Destroy(gameObject); } } ); } ); } ); } ); }
IEnumerable <Instruction> RunEndGameCredits() { _OverlayCanvas.gameObject.SetActive(true); _StartingText.rectTransform.localPosition = new Vector3(_StartingText.rectTransform.localPosition.x, -100f, _StartingText.rectTransform.localPosition.z); _StartingText.rectTransform.LookAt(-Camera.main.transform.position); _StartingText.color = Color.white; //_OverlayCanvas.transform.GetChild(0).GetComponent<Image>().CrossFadeAlpha(1f, 5f, true); LeanTween.color(_OverlayCanvas.transform.GetChild(0).transform as RectTransform, Color.black, 5f).setUseEstimatedTime(true); var text = _OverlayCanvas.transform.GetChild(1).GetComponent <Text>(); //text.gameObject.SetActive(true); text.color = new Color(1f, 1f, 1f, 0f); //text.CrossFadeAlpha(1f, 5f, true); //LeanTween.color(text.rectTransform, new Color(1f, 1f, 1f, 1f), 5f).setUseEstimatedTime(true); LeanTween.textAlpha(text.rectTransform, 1f, 5f).setUseEstimatedTime(true); text.text = LargeSize + "Your score!\n" + EndSize + GameMachine.Instance.Points + "\n\nProperty Damage: " + GameMachine.Instance.Damage.ToString("C") + "\n\nHighest Multiplier Gained: " + Multiplier.Highest; //LeanTween.value(gameObject, // c => { // _OverlayCanvas.transform.GetChild(0).GetComponent<Image>().CrossFadeAlpha(1f, 5f, true); // }, // new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 1f), 5f); GameMachine.Instance.OpenTween("CreditsScroller", 190); LeanTween.moveLocalY(_StartingText.gameObject, 0f, 10f).onComplete = () => GameMachine.Instance.CloseTween("CreditsScroller", 190); yield return(ControlFlow.Call(Wait(10f))); _OverlayCanvas.transform.GetChild(2).gameObject.SetActive(true); }
protected override LTDescr TweenRun(bool reversed, float time) { float alpha = Mathf.Clamp01(reversed ? alphaRange.To : alphaRange.From); Image image = GetComponent <Image> (); if (image != null) { return(LeanTween.alpha((RectTransform)transform, alpha, time)); } Text text = GetComponent <Text> (); if (text != null) { return(LeanTween.textAlpha((RectTransform)transform, alpha, time)); } Renderer renderer = GetComponent <Renderer> (); if (renderer != null) { return(LeanTween.alpha(gameObject, alpha, time)); } return(null); }
void Start() { rectTransform = GetComponent <RectTransform>(); LeanTween.alpha(rectTransform, 0f, 0f); LeanTween.textAlpha(rectTransform, 0f, 0f); button = GetComponent <Button>(); }
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); // *********** 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); }
public void SetVisible(bool isVisible) { if (isVisible != button.interactable) { button.interactable = isVisible; enabled = isVisible; LeanTween.alpha(rectTransform, isVisible ? 1f : 0f, 0.5f); LeanTween.textAlpha(rectTransform, isVisible ? 1f : 0f, 0.5f); } }
/// <summary> /// Fades out the label. /// </summary> void FadeOut() { /*TweenColor tc = TweenColor.Begin(gameObject, fadeOutDuration, ec); * tc.from = sc; * tc.method = method;*/ LTDescr t = LeanTween.textAlpha(rect, 0, fadeInDuration); t.setFrom(1); t.setEase(easing); }
void TextComplete() { if (StartText.GetComponent <Text>().color.a == 0.0f) { LeanTween.textAlpha(StartText, 1f, 1.0f).setOnComplete(TextComplete); } else if (StartText.GetComponent <Text>().color.a == 1f) { LeanTween.textAlpha(StartText, 0.0f, 1.0f).setOnComplete(TextComplete); } }
private void Awake() { m_scrimTweenId = -1; DontDestroyOnLoad(gameObject); Text cta = screens[0].transform.FindChild("Label").GetComponent <Text>(); cta.color = new Color(1, 1, 1, 0); int pulseTweenId = LeanTween.textAlpha(cta.rectTransform, 1, 0.5f).setEase(LeanTweenType.easeInOutSine).setLoopPingPong().id; }
private void OnEnable() { if (rect == null) { rect = GetComponent <RectTransform>(); } LeanTween.cancel(rect); LeanTween.textAlpha(rect, 0, duration) .setDelay(delay) .setLoopPingPong() .setEase(tweenType); }
void ChangeAlpha(int _index) { if (canvasGroup) { if (Math.Abs(canvasGroup.alpha - data[_index].alpha) > TOLERANCE) { LeanTween.alphaCanvas(canvasGroup, data[_index].alpha, data[_index].duration) .setEase(data[_index].easeType) .setDelay(data[_index].delay) .setLoopCount(data[_index].loopCount); performEvents = true; } } if (rectTransform && image) { if (Math.Abs(image.color.a - data[_index].alpha) > TOLERANCE) { LeanTween.alpha(rectTransform, data[_index].alpha, data[_index].duration) .setEase(data[_index].easeType) .setDelay(data[_index].delay) .setLoopCount(data[_index].loopCount); performEvents = true; } } else if (spriteRenderer) { if (Math.Abs(spriteRenderer.color.a - data[_index].alpha) > TOLERANCE) { LeanTween.alpha(gameObject, data[_index].alpha, data[_index].duration) .setEase(data[_index].easeType) .setDelay(data[_index].delay) .setLoopCount(data[_index].loopCount); performEvents = true; } } else if (txt) { if (Math.Abs(txt.color.a - data[_index].alpha) > TOLERANCE) { LeanTween.textAlpha(rectTransform, data[_index].alpha, data[_index].duration) .setEase(data[_index].easeType) .setDelay(data[_index].delay) .setLoopCount(data[_index].loopCount); performEvents = true; } } }
/// <summary> /// /// </summary> /// <param name="count"></param> public void ShowComboCount(int count) { //Size if (count <= _comboCount_s) { _comboText.fontSize = _comboFontSize_s; _comboText.color = _comboColor_s; } else if (count <= _comboCount_m) { _comboText.fontSize = _comboFontSize_m; _comboText.color = _comboColor_m; } else if (count <= _comboCount_l) { _comboText.fontSize = _comboFontSize_l; _comboText.color = _comboColor_l; } else { _comboText.fontSize = _comboFontSize_xl; _comboText.color = _comboColor_xl; } _comboText.transform.rotation = Quaternion.identity; _comboText.text = "x " + count.ToString(); //Bg if (!_comboBg.gameObject.activeSelf) { _comboBg.gameObject.SetActive(true); } if (_comboTotalBg.gameObject.activeSelf) { _comboTotalBg.gameObject.SetActive(false); } LeanTween.cancel(_comboBg.gameObject); LeanTween.alpha(_comboBg.gameObject, .01f, _comboFeedbackTime); //_comboText.color = Color.white; if (!_comboText.transform.parent.gameObject.activeInHierarchy) { _comboText.transform.parent.gameObject.SetActive(true); } LeanTween.cancel(_comboText.gameObject); LeanTween.cancel(_comboText.transform.parent.gameObject); _comboText.transform.parent.localScale = Vector3.one; _comboText.transform.parent.gameObject.transform.localPosition = Vector3.zero; LeanTween.scale(_comboText.transform.parent.gameObject, Vector3.one * 1.5f, _comboFeedbackTime * 0.5f); LeanTween.moveLocalY(_comboText.transform.parent.gameObject, _comboOffset, _comboFeedbackTime); LeanTween.textAlpha(_comboText.rectTransform, .01f, _comboFeedbackTime).setOnComplete(() => { _comboText.transform.parent.gameObject.SetActive(false); }); }
public IEnumerator DisplaySceneName(StoryScene scene) { Title.text = scene.Data.Name; LeanTween.textAlpha(Title.rectTransform, 1.0f, TitleFadeInTime).tweenType = LeanTweenType.easeInOutQuad; yield return(new WaitForSeconds(TitleFadeInTime)); yield return(new WaitForSeconds(TitleShowTime)); LeanTween.textAlpha(Title.rectTransform, 0.0f, TitleFadeOutTime).tweenType = LeanTweenType.easeInOutQuad; yield return(new WaitForSeconds(TitleFadeOutTime)); }
void Awake() { Time.timeScale = 1; mWaitingForAuth = false; //PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestServerAuthCode(false /* Don't force refresh */).Build(); //PlayGamesPlatform.InitializeInstance(config); //PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.Activate(); LeanTween.textAlpha(StartText, 1f, 1.0f).setOnComplete(TextComplete); if (Application.platform == RuntimePlatform.Android) { Application.targetFrameRate = 60; } }
/// <summary> /// Shows the level start text. /// </summary> public void ShowLevelStart() { levelStartText.gameObject.SetActive(true); leveltext.text = "WAVE " + GameManager.Instance.Level; LeanTween.textAlpha(levelStartText, 1.0f, 1.0f) .setEase(LeanTweenType.easeOutSine) .setOnComplete(() => { LeanTween.textAlpha(levelStartText, 0.0f, 0.5f) .setEase(LeanTweenType.easeOutSine) .setDelay(textDuration) .setOnComplete(() => { levelStartText.gameObject.gameObject.SetActive(false); }); }); }
/// <summary> /// Fades in the label wait few seconds then fade out. /// </summary> void FadeIn() { /*TweenColor tc = TweenColor.Begin(gameObject, fadeInDuration, ec); * tc.from = sc; * tc.method = method;*/ if (LeanTween.isTweening(rect.gameObject)) { LeanTween.cancel(rect.gameObject); } LTDescr t = LeanTween.textAlpha(rect, 1, fadeInDuration); t.setFrom(0); t.setEase(easing); LeanTween.delayedCall(hideDelay, FadeOut); }
protected override IEnumerator _Tutorial() { phone.SetActive(true); for (int i = 1; i < grasses.Length; i++) { grasses[i].SetActive(false); } grasses[0].transform.position = mower.transform.position + new Vector3(3, 3); SetupGrass(grasses[0]); LeanTween.textAlpha(tutorialText.rectTransform, 1f, .25f).setEase(LeanTweenType.easeInOutQuad); tutorialText.text = "Tilt your device"; yield return(MicroMixManager.Instance.WaitSecondsPause(.15f)); LeanTween.rotateZ(phone, 90 - 45, 1f); LeanTween.rotateZ(mower.gameObject, 270 - 45, 1f); yield return(MicroMixManager.Instance.WaitSecondsPause(1f)); LeanTween.rotateZ(phone, 90 + 45, 2f); LeanTween.rotateZ(mower.gameObject, 270 + 45, 2f); yield return(MicroMixManager.Instance.WaitSecondsPause(2f)); LeanTween.rotateZ(phone, 90 - 45, 2f); LeanTween.rotateZ(mower.gameObject, 270 - 45, 2f); yield return(MicroMixManager.Instance.WaitSecondsPause(2f)); LeanTween.textAlpha(tutorialText.rectTransform, 0f, .25f).setEase(LeanTweenType.easeInOutQuad); LeanTween.move(mower, grasses[0].transform.position, .5f); yield return(MicroMixManager.Instance.WaitSecondsPause(.3f)); grasses[0].SetActive(false); yield return(MicroMixManager.Instance.WaitSecondsPause(.2f)); for (int i = 0; i < grasses.Length; i++) { grasses[i].SetActive(true); } phone.SetActive(false); }
public void OnClickStage(Button btn) { int StageNum = int.Parse(btn.GetComponentInChildren <Text>().text); string StageName = "STAGE_" + StageNum; StageManager.fileNameForEdit = null; StageManager.stageNum = (E_STAGE)StageNum; if (StageNum <= Count) { SceneManager.LoadScene(StageName); } else { { Alert.gameObject.SetActive(true); if (Alert.GetComponent <Text>().color.a == 0) { LeanTween.textAlpha(Alert, 1f, 1.0f).setOnComplete(AlertComplete); } } } }
void CreateScore(int score) // Canvas에 점수를 표시한다. { GameObject temp = Instantiate(Score) as GameObject; temp.transform.parent = canvas.transform; temp.transform.localScale = new Vector3(1f, 1f, 1f); if (score > 0) // 스코어가 0보다 큰 값이면 { temp.GetComponent <Text>().text = "+" + score.ToString(); // 얻은 점수를 프리펩에 전달 MyScore += score; // 내 점수에 합산 TotalScore.text = MyScore.ToString(); // Canvas에 현재 토탈 점수를 표시 if (MyScore > int.Parse(HighScore.text)) // 현재 토탈 점수가 하이스코어를 넘어섰으면 { HighScore.text = MyScore.ToString(); // 하이스코어 설정 PlayerPrefs.SetString("HighScore", HighScore.text); // 디바이스에 하이스코어 저장 } } else // 스코어가 0보다 작은 값이면 MISS가 뜨게 한다. { temp.GetComponent <Text>().text = "MISS"; temp.GetComponent <Text>().color = Color.red; } // 생성한 Score 프리펩을 Canvas 내의 좌표로 변환시켜 위치를 설정해준다. RectTransform rect = temp.GetComponent <RectTransform>(); rect.anchoredPosition = WorldToCanvas(CatLandedBlock.transform.position); // 스코어를 위로 이동시켜 올라가는 효과를 준다. temp.transform.DOLocalMoveY(temp.transform.localPosition.y + 200f, 1.0f).SetEase(Ease.OutBack); // 스코어를 좌우로 랜덤하게 이동시켜 여러개의 점수를 볼 수 있도록 연출한다. temp.transform.DOLocalMoveX(temp.transform.localPosition.x + Random.Range(-100f, 100f), 1.0f); // DOTween 플러그인에는 알파값을 조절하는 함수가 없어 이 부분에만 LeanTween을 사용했다. LeanTween.textAlpha(rect, 0f, 1.0f); // 1초 동안 알파값이 0f가 되도록 서서히 사라지게 한다. Destroy(temp, 1.0f); // 1초 후에 스코어를 삭제한다. }
protected override IEnumerator _Tutorial() { phone.SetActive(true); player.SetAngle(Mathf.PI); campfire.SetAngle(0); campfire.Stop(); campfire.SetupLogs(); float mallowAngle = Mathf.PI; for (int i = 0; i < mallows.Length; i++) { mallowAngle += Mathf.PI / 4; mallows[i].transform.position = new Vector3(Mathf.Cos(mallowAngle), Mathf.Sin(mallowAngle)) * distance; mallows[i].Randomize(); } LeanTween.textAlpha(tutorialText.rectTransform, 1f, .25f).setEase(LeanTweenType.easeInOutQuad); tutorialText.text = "Tilt your device"; campfire.RotateTowards(Mathf.PI, 2f); yield return(MicroMixManager.Instance.WaitSecondsPause(1f)); LeanTween.rotateZ(phone, 90 + 45, .5f); player.RotateTowards(2.5f * Mathf.PI, 1.5f); yield return(MicroMixManager.Instance.WaitSecondsPause(2f)); LeanTween.rotateZ(phone, 90 - 45, .5f); player.RotateTowards(1.5f * Mathf.PI, 1f); LeanTween.textAlpha(tutorialText.rectTransform, 0f, .25f).setEase(LeanTweenType.easeInOutQuad); yield return(MicroMixManager.Instance.WaitSecondsPause(1f)); for (int i = 0; i < mallows.Length; i++) { mallows[i].gameObject.SetActive(true); } phone.SetActive(false); }
public void OnMultiplier(int amount) { if (amount > 1) { int textAmount = amount; multiplierText.CrossFadeAlpha(1, 0.2f, true); multiplierText.sprite = (amount == 2) ? sprite2x : sprite3x; LeanTween.cancel(multiplierText.gameObject); multiplierText.rectTransform.localScale = new Vector3(1, 1, 1); float desiredSize = (amount == 2) ? pulseSize.x : pulseSize.y; LeanTween.scale(multiplierText.rectTransform, new Vector3(desiredSize, desiredSize, 1), (amount == 2)? 0.4f : 0.2f).setEaseInOutCirc().setLoopPingPong(); LeanTween.textAlpha(multiplierText.rectTransform, 0, 0.3f).setEaseInOutCirc().setLoopPingPong(1); } else { LeanTween.cancel(multiplierText.gameObject); multiplierText.CrossFadeAlpha(0, 0.2f, true); } }
protected override void ApplyTween(GameObject go) { foreach (Image image in go.GetComponentsInChildren <Image>()) { if (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; } } } foreach (Text text in go.GetComponentsInChildren <Text>()) { if (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; } } } foreach (TextMesh textMesh in go.GetComponentsInChildren <TextMesh>()) { if (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; } } } }
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; } } } }
void AlertComplete() { LeanTween.textAlpha(Alert, 0f, 1.0f); }
private void buildTween(LeanTweenItem item, float delayAdd, bool generateCode) { float delay = item.delay + delayAdd; bool code = generateCode; float d = item.duration; // Debug.Log("item:"+item.action); if (item.action == TweenAction.ALPHA) { tween = code ? append("alpha", item.to.x, d) : LeanTween.alpha(gameObject, item.to.x, d); } else if (item.action == TweenAction.ALPHA_VERTEX) { tween = code ? append("alphaVertex", item.to.x, d) : LeanTween.alphaVertex(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE) { tween = code ? append("move", item.to, d) : LeanTween.move(gameObject, item.to, d); } else if (item.action == TweenAction.MOVE_LOCAL) { tween = code ? append("moveLocal", item.to, d) : LeanTween.moveLocal(gameObject, item.to, d); } else if (item.action == TweenAction.MOVE_LOCAL_X) { tween = code ? append("moveLocalX", item.to.x, d) : LeanTween.moveLocalX(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_LOCAL_Y) { tween = code ? append("moveLocalY", item.to.x, d) : LeanTween.moveLocalY(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_LOCAL_Z) { tween = code ? append("moveLocalZ", item.to.x, d) : LeanTween.moveLocalZ(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_X) { tween = code ? append("moveX", item.to.x, d) : LeanTween.moveX(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_Y) { tween = code ? append("moveY", item.to.x, d) : LeanTween.moveY(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_Z) { tween = code ? append("moveZ", item.to.x, d) : LeanTween.moveZ(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_CURVED) { tween = code ? append("move", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.move(gameObject, item.bezierPath.vec3, d); if (item.orientToPath) { if (code) { codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")"); } else { tween.setOrientToPath(item.orientToPath); } } if (item.isPath2d) { if (code) { codeBuild.Append(".setOrientToPath2d(true)"); } else { tween.setOrientToPath2d(item.isPath2d); } } } else if (item.action == TweenAction.MOVE_CURVED_LOCAL) { tween = code ? append("moveLocal", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.moveLocal(gameObject, item.bezierPath.vec3, d); if (item.orientToPath) { if (code) { codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")"); } else { tween.setOrientToPath(item.orientToPath); } } if (item.isPath2d) { if (code) { codeBuild.Append(".setOrientToPath2d(true)"); } else { tween.setOrientToPath2d(item.isPath2d); } } } else if (item.action == TweenAction.MOVE_SPLINE) { tween = code ? append("moveSpline", item.splinePath ? item.splinePath.splineVector() : null, d) : LeanTween.moveSpline(gameObject, item.splinePath.splineVector(), d); if (item.orientToPath) { if (code) { codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")"); } else { tween.setOrientToPath(item.orientToPath); } } if (item.isPath2d) { if (code) { codeBuild.Append(".setOrientToPath2d(true)"); } else { tween.setOrientToPath2d(item.isPath2d); } } } else if (item.action == TweenAction.ROTATE) { tween = code ? append("rotate", item.to, d) : LeanTween.rotate(gameObject, item.to, d); } else if (item.action == TweenAction.ROTATE_AROUND) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAround(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAround(gameObject, item.axis, item.to.x, d); } } else if (item.action == TweenAction.ROTATE_AROUND_LOCAL) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAroundLocal(gameObject, item.axis, item.to.x, d); } } else if (item.action == TweenAction.ROTATE_LOCAL) { tween = code ? append("rotateLocal", item.to, d) : LeanTween.rotateLocal(gameObject, item.to, d); } else if (item.action == TweenAction.ROTATE_X) { tween = code ? append("rotateX", item.to.x, d) : LeanTween.rotateX(gameObject, item.to.x, d); } else if (item.action == TweenAction.ROTATE_Y) { tween = code ? append("rotateY", item.to.x, d) : LeanTween.rotateY(gameObject, item.to.x, d); } else if (item.action == TweenAction.ROTATE_Z) { tween = code ? append("rotateZ", item.to.x, d) : LeanTween.rotateZ(gameObject, item.to.x, d); } else if (item.action == TweenAction.SCALE) { tween = code ? append("scale", item.to, d) : LeanTween.scale(gameObject, item.to, d); } else if (item.action == TweenAction.SCALE_X) { tween = code ? append("scaleX", item.to.x, d) : LeanTween.scaleX(gameObject, item.to.x, d); } else if (item.action == TweenAction.SCALE_Y) { tween = code ? append("scaleY", item.to.x, d) : LeanTween.scaleY(gameObject, item.to.x, d); } else if (item.action == TweenAction.SCALE_Z) { tween = code ? append("scaleZ", item.to.x, d) : LeanTween.scaleZ(gameObject, item.to.x, d); } #if !UNITY_4_3 && !UNITY_4_5 else if (item.action == TweenAction.CANVAS_MOVE) { tween = code ? appendRect("move", item.to, d) : LeanTween.move(GetComponent <RectTransform>(), item.to, d); } else if (item.action == TweenAction.CANVAS_SCALE) { tween = code ? appendRect("scale", item.to, d) : LeanTween.scale(GetComponent <RectTransform>(), item.to, d); } else if (item.action == TweenAction.CANVAS_ROTATEAROUND) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAround(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAround(GetComponent <RectTransform>(), item.axis, item.to.x, d); } } else if (item.action == TweenAction.CANVAS_ROTATEAROUND_LOCAL) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAroundLocal(GetComponent <RectTransform>(), item.axis, item.to.x, d); } } else if (item.action == TweenAction.CANVAS_ALPHA) { tween = code ? appendRect("alpha", item.to.x, d) : LeanTween.alpha(GetComponent <RectTransform>(), item.to.x, d); } else if (item.action == TweenAction.CANVAS_COLOR) { tween = code ? appendRect("color", item.colorTo, d) : LeanTween.color(GetComponent <RectTransform>(), item.colorTo, d); } else if (item.action == TweenAction.TEXT_ALPHA) { tween = code ? appendRect("textAlpha", item.to.x, d) : LeanTween.textAlpha(GetComponent <RectTransform>(), item.to.x, d); } else if (item.action == TweenAction.TEXT_COLOR) { tween = code ? appendRect("textColor", item.colorTo, d) : LeanTween.textColor(GetComponent <RectTransform>(), item.colorTo, d); } else if (item.action == TweenAction.CANVAS_PLAYSPRITE) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.play(rectTransform, sprites).setFrameRate(" + item.frameRate + "f)"); } else { tween = LeanTween.play(GetComponent <RectTransform>(), item.sprites).setFrameRate(item.frameRate); } } #endif else if (item.action == TweenAction.COLOR) { tween = code ? append("color", item.colorTo, d) : LeanTween.color(gameObject, item.colorTo, d); } else if (item.action == TweenAction.DELAYED_SOUND) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.delayedSound(gameObject, passAudioClipHere, " + vecToStr(item.from) + ", " + d + "f)"); } else { tween = LeanTween.delayedSound(gameObject, item.audioClip, item.from, item.duration); } } else { tween = null; Debug.Log("The tween '" + item.action.ToString() + "' has not been implemented. info item:" + item); return; } // Append Extras if (generateCode) { if (delay > 0f) { codeBuild.Append(".setDelay(" + delay + "f)"); } } else { tween = tween.setDelay(delay); } if (item.ease == LeanTweenType.animationCurve) { if (generateCode) { codeBuild.Append(".setEase("); append(item.animationCurve); codeBuild.Append(")"); } else { tween.setEase(item.animationCurve); } } else { if (generateCode) { if (item.ease != LeanTweenType.linear) { codeBuild.Append(".setEase(LeanTweenType." + item.ease + ")"); } } else { tween.setEase(item.ease); } } // Debug.Log("curve:"+item.animationCurve+" item.ease:"+item.ease); if (item.between == LeanTweenBetween.FromTo) { if (generateCode) { codeBuild.Append(".setFrom(" + item.from + ")"); } else { tween.setFrom(item.from); } } if (item.doesLoop) { if (generateCode) { codeBuild.Append(".setRepeat(" + item.loopCount + ")"); } else { tween.setRepeat(item.loopCount); } if (item.loopType == LeanTweenType.pingPong) { if (generateCode) { codeBuild.Append(".setLoopPingPong()"); } else { tween.setLoopPingPong(); } } } if (generateCode) { codeBuild.Append(";\n"); } }
public void FadeText(bool value) { float to = (value) ? 0f : 1f; LeanTween.textAlpha(textMesh.GetComponent <RectTransform>(), to, .3f); }
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 <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; } } } }
public static LTDescr LTTextAlpha(this RectTransform rectTransform, float to, float time) { return(LeanTween.textAlpha(rectTransform, to, time)); }