Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMP reveal effect per char/line #192

Open
dburongarcia opened this issue Oct 27, 2019 · 4 comments
Open

TMP reveal effect per char/line #192

dburongarcia opened this issue Oct 27, 2019 · 4 comments
Assignees

Comments

@dburongarcia
Copy link

  • Platform: Editor(Windows) Standalone(Windows)
  • Unity: 2019.2.8
  • UIEffect: v3.2

Hello, I wonder if it's possible to get an advanced reveal effect with TMP. Right now I'm using a reveal effect using the alpha value of the chars vertex colors, allowing a typewriter or fade effect per char.

I would like something like a dissolving effect per char, or at least per line. To make it per line I thought of dividing each line of text in a different TMPText and applying directly the dissolve effect to each one, but that's not optimal for dynamic text and it won't work for individual chars.

Congratulations for this wonderful component. 事前にどうもありがとうございました。

@dburongarcia
Copy link
Author

dburongarcia commented Oct 27, 2019

Hello again, I was looking at #86 and maybe it would be possible to add a new Effect Area (like line or word) and a new Advanced Option below Effect Area (simultaneous and continuous) so every character could appear/disappear at the same time or after each other.

Having a UI dissolve for revealing each character continuously would be great combined with dynamic duration to create astonishing TMP effects. @mob-sakai Let me know if I could help to achieve it.

@mob-sakai
Copy link
Owner

Hi @dburongarcia

Thank you for the feature request!
Like a typewriter, the effect independent for each character is probably possible, but difficult.

I came up with two solutions:

Solution 1: Shader controls the typewriter.

Give start time and duration as uv3, and calculate in shader.
The shader need new variants.

Solution2: Assign a parameter texture to each character

The script controls the effect.

I think solution 2 is preferred. :)

@dburongarcia
Copy link
Author

dburongarcia commented Oct 28, 2019

Hi @mob-sakai thank you for your reply.
As you said, solution2 doesn't seem the best way to do it. But I'm not sure about how to implement solution 1. Right now for the typewriter effect I'm just counting characters and changing the alpha from 0 to 255 for each of the vertices of the character:

int vertexIndex = text.character[i].vertexIndex;
vertexColor[vertexIndex + 0].a+=fadeRate
vertexColor[vertexIndex + 1].a+=fadeRate
vertexColor[vertexIndex + 2].a+=fadeRate
vertexColor[vertexIndex + 3].a+=fadeRate

Maybe something similar could be implemented in the shader.

@mob-sakai
Copy link
Owner

Ah I see.
It's also a good idea to use alpha as an effectFactor. :)

@mob-sakai mob-sakai self-assigned this Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants