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

Add scrolling text component and tag #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chrislee0419
Copy link
Contributor

Scrolling text for banners and other fancy stuff

Acts the same as a regular text tag (although it's missing some of the properties that the regular text tag has) until the text given to it is longer than the RectTransform. Once the text is longer, the text is scaled down to fit until the textWidthRatioThreshold (ratio between text width vs container width) is reached. This was done so the animation doesn't activate for text that is just barely longer than the container.

This example view controller results in this

Also, added that enum parser in Parse. Probably should've been its own commit but ¯\(ツ)

@monkeymanboy
Copy link
Owner

I'd suggest making ScrollingText inherit TextMeshProUGUI so that you can use it like normal text without things breaking. This also comes with the advantage that the TextMeshProUGUI TypeHandler will work with it so you will be able to use all text properties. Would also just make the overall implementation cleaner I think.

@chrislee0419
Copy link
Contributor Author

I originally wanted to do that (adding the TextMeshProUGUI into a ExternalComponents component), but I needed a way to stop and restart the animation coroutine after reassigning the text or font size.

So pretty much, any time the TextMeshProUGUI has some property changed that also changes the width of its RectTransform, the component needs to recalculate some ratios to determine whether to restart the scroll animation. Hence why there are those text and fontSize properties in the ScrollingText class.

Is there any way around that? As far as I know, there doesn't seem to be any kind of event that I can hook onto whenever the embedded text component has its RectTransform changed.

@monkeymanboy
Copy link
Owner

It's a Graphic so you should be able to do what you need by registering your method with RegisterDirtyLayoutCallback.

@chrislee0419
Copy link
Contributor Author

Finally got around to finishing this. I also added in the test view I was using for this into the TestViewController.

Maybe this would be useful in SongCore to get rid of the ellipses for the custom difficulty labels now that the don't wrap to a new line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants