BeatSaberMarkupLanguage
BeatSaberMarkupLanguage copied to clipboard
Add scrolling text component and tag
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 ¯\(ツ)/¯
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.
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.
It's a Graphic so you should be able to do what you need by registering your method with RegisterDirtyLayoutCallback.
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.