Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Scollable Text?

A topic by draque created Jul 25, 2024 Views: 93 Replies: 4
Viewing posts 1 to 3
(1 edit)

Is there an example of the best way to make scrollable text? I am replacing TextMeshPro objects with SuperTextMesh ones, and they do not seem to get along with a ScrollRect/Viewport/Mask setup. Essentially it is just a dialog box, but I would like the player to be able to scroll back in the conversation if they choose to. I am thinking that rather than adapting SuperTextMesh to this previous setup, I should just re-do this part completely. Is there any good code or example projects I can look at where this is done?

I looked in the examples folder and did not see anything there that quite did what I needed. Thanks!

Developer

Hm, the shaders in Super Text Mesh *should* be updated to work with both sprite and UI Masks, but not Rect Masks, just yet. (Unity's documentation on rect masks was severely lacking) Were the dialogue boxes you were looking at using rect masks? If so, I'll ask to replace them with regular masks for the time being!

(4 edits)

Hrm, I am pretty sure that it's a rect mask, since those are compatible with scroll bars...

Do you possibly have a link to example code to show how this is best done? I have been looking through github to try to find examples but am having some trouble.  Specifically, all examples I find online presume that all text will use rect masks, which is how I currently have it set up. They limit vertical movement automatically to just the size of whatever is contained within them, which is really nice. It seems like the size of the SuperTextMesh box is not defined in the same way as a TextMeshPro box though, which is what prevents theRectMask from recognizing where it's able to scroll to.

Ok, striking everything I said there... I am using a normal mask rather than a rect mask. It's not detecting that the text is longer than the current view port, so when I try to scroll down, it snaps back up. If you look at the example below, you'll see that the box never detects that its boundaries have content which has expanded past them, and the vertical scroll bar remains hidden, despite this. When I stash my current progress with git, all settings are the same, but with a TMP, and it functions normally.

VIEWPORT SETTINGS:


STM Settings:


RESULT:

When I try to scroll down, it moves slightly, then snaps back.

Developer

Oh! I see, it's probably just a rect fitting issue! Attach the component "Content Size Fitter" to the STM object, and set the vertical size to "preferred" and things *should* work as you want if i'm understanding correctly... That will resize the rect around STM to match its internal text bounds.

That was the trick to it, thank you!