private void UpdateMotion() { if (elapsedMotionSeconds > TotalMotionSeconds) { return; } elapsedMotionSeconds += LoopEngine.DeltaSeconds; for (int i = 0; i < charList.Count; ++i) { MotionChar character = charList[i]; float indexTime = (elapsedMotionSeconds - i * CharMotionDelaySeconds) / CharMotionSeconds; float motionTime = Mathf.Pow(Mathf.Clamp01(indexTime), 0.5f); float motionTimeInvert = 1f - motionTime; character.Offset = MotionStartOffset * motionTimeInvert; character.Alpha = MotionStartAlpha + (1f - MotionStartAlpha) * motionTime; } }
private void UpdateChars() { ClearChars(); MotionChar sampleChar = charPool.GetObject(); SetCharStyle(sampleChar); sampleChar.Character = 'A'; Vector2 charPosition = Vector2.zero; for (int i = 0; i < text.Length; ++i) { char characterSrc = text[i]; switch (characterSrc) { case '\r': break; case '\n': charPosition.x = 0f; charPosition.y -= sampleChar.Bounds.y + FontSize * 0.2f; break; default: MotionChar character = charPool.GetObject(); charList.Add(character); SetCharStyle(character); character.Character = text[i]; character.Position = charPosition; charPosition.x += character.Bounds.x; break; } } charPool.ReleaseObject(sampleChar); }
private void SetCharStyle(MotionChar character) { character.Font = Font; character.FontSize = FontSize; character.FontColor = FontColor; }
private void ReleaseCharTask(MotionChar value) { value.GameObject.SetActive(false); }
private void GetCharTask(MotionChar value) { value.GameObject.SetActive(true); }
private void DisposeCharTask(MotionChar value) { value.Dispose(); }