Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Swap part of text without rebuilding it?

A topic by HenryChinaski created Feb 07, 2020 Views: 196 Replies: 1
Viewing posts 1 to 2

Hi,

I use the Super Text Mesh Asset to display lines of dialogue. At the end of the dialogue I wanted a smallbutton icon - indicating, that the player needs to press it - so I used quads for that.

My problem now is that it doesn't feel right if there is no reaction of the button icon the moment the player presses the button. What I would like to do is to swap the <q=pressA> with <q=pressA_On> without rebuilding the total mesh. Is there a way to do this?

What I tried is:

                                string newText = Conversation_TextMesh_PC.text.Substring(0, Conversation_TextMesh_PC.text.Length - 2) + "_On>";
                                Conversation_TextMesh_PC.text = newText;
                                Conversation_TextMesh_PC.readDelay = 0f;
                                Conversation_TextMesh_PC.Read();

But the mesh will rebuild in total anyway.

Best regards, Daniel

Developer

Hey!


Unfortunately, there's no way to replace a quad upon a button press without Rebuilding the whole mesh. (Unless you were to edit the actual mesh directly...) Alternatively, you can use the "info" list to grab the position of the final character in a text mesh and move a sprite renderer to that position! Or, you could call Undraw() and make the text undraw in reverse order so the button disappears first. There's a couple different ways you can achieve this responsiveness!

That said, the code you posted should also work just fine, even if it is a bit heavier than just changing the sprite of a sprite renderer. A lot of STM's overhead at the moment is in-editor... even just clicking away from the massive inspector window will improve performance if it's taking a hit!