mob-sakai / UIEffect

UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
https://github.com/mob-sakai/UIEffect
MIT License
5.62k stars 773 forks source link

TMP reveal effect per char/line #192

Open dburongarcia opened 4 years ago

dburongarcia commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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