void SetTextLerpView(float param) { float ease = EaseUtility.EasedLerp(0, 1, param, animationEaseType); if (scaleTarget == ScaleTarget.Self) { textComponent.transform.localScale = Vector3.LerpUnclamped(startScale, Vector3.one, ease); } else { textComponent.transform.parent.localScale = Vector3.LerpUnclamped(startScale, Vector3.one, ease); } Color c = initShadowColor; if (isChangeOpacity) { textComponent.color = new Color(textComponent.color.r, textComponent.color.g, textComponent.color.b, ease); if (isHasShadow) { shadow.effectColor = new Color(c.r, c.g, c.b, Mathf.Lerp(0, c.a, param)); } } else { textComponent.color = new Color(textComponent.color.r, textComponent.color.g, textComponent.color.b, 1); if (isHasShadow) { shadow.effectColor = new Color(c.r, c.g, c.b, Mathf.Lerp(0, c.a, 1)); } } }
IEnumerator ChangeNumberAnimation(int targetNumber, float numberDuration, string extraTextInFront = "", string extraTextInEnd = "", float delay = 0) { if (delay != 0) { yield return(new WaitForSeconds(delay)); } int startNumber; if (!int.TryParse(textComponent.text, out startNumber)) { startNumber = 0; } float progress = 0; float v = 1f / numberDuration; int lastNumber = startNumber; while (progress <= 1) { progress += v * Time.deltaTime; float easedValue = EaseUtility.EasedLerp(startNumber, targetNumber, progress, numberEaseType); int tmp = Mathf.FloorToInt(easedValue); if (lastNumber != tmp) { lastNumber = tmp; SetTextAnimation(extraTextInFront + lastNumber.ToString() + extraTextInEnd); } yield return(null); } SetTextAnimation(extraTextInFront + targetNumber.ToString() + extraTextInEnd); }
IEnumerator Shaking(Transform _transform, Vector3 magnetude, float duration, float motion, bool isSexy = false, bool isIgnoreTimeScale = false, EaseStyle easeStyle = EaseStyle.QuadEaseOut) { float lifeTime = duration; float age = lifeTime; Vector3 offset = Vector3.zero; Vector2 seedX = Vector2Extension.RandomInSqaure * 10f; Vector2 seedY = Vector2Extension.RandomInSqaure * 10f; Vector2 seedZ = Vector2Extension.RandomInSqaure * 10f; Vector2 motionVectX = Vector2Extension.RandomOnCircle * motion; Vector2 motionVectY = Vector2Extension.RandomOnCircle * motion; Vector2 motionVectZ = Vector2Extension.RandomOnCircle * motion; while (_transform != null & age > 0) { _transform.position -= offset; float deltaTime = (isIgnoreTimeScale) ? Time.unscaledDeltaTime : Time.deltaTime; age -= deltaTime; float power = (age / lifeTime); power *= EaseUtility.EasedLerp(0f, 1f, power, easeStyle); seedX += ((isSexy) ? motionVectX * power : motionVectX) * deltaTime; seedY += ((isSexy) ? motionVectY * power : motionVectY) * deltaTime; seedZ += ((isSexy) ? motionVectZ * power : motionVectZ) * deltaTime; offset = new Vector3( Mathf.PerlinNoise(seedX.x, seedX.y), Mathf.PerlinNoise(seedY.x, seedY.y), Mathf.PerlinNoise(seedZ.x, seedZ.y)); //***** Center the noise signal ***** offset -= Vector3.one * 0.5f; offset *= 2f; offset *= power; offset = new Vector3( offset.x * magnetude.x, offset.y * magnetude.y, offset.z * magnetude.z); //***** Center the noise signal ***** _transform.position += offset; yield return(null); } if (_transform != null) { _transform.position -= offset; } yield break; }