Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Text become invisible when rotate with a sprite inside

A topic by iiley created Nov 12, 2020 Views: 166 Replies: 4
Viewing posts 1 to 5
(1 edit)

The code is very simple, i just made a dialog behind the text, and auto adjust its size:

    public SpriteRenderer spr;

    void Update()
    {
        var stm = GetComponent<SuperTextMesh>();
        Vector2 s = new Vector2(stm.preferredWidth + 2f, stm.preferredHeight + 1f);
        spr.size = s;
    }

Developer

Hey!

This has to do with how Unity handles the Z buffer and/or draw order. If you're making a 2D textbox with sprites, attach the included utility script (I believe names "STMChangeDraworder" or something to that degree) to change the draw order vs other sprites, and force STM to always render in front of the background!

It works, thank you.

BTW, i'm planning to use Super Text Mesh to my new project, which is a MMO mobile game, i'm wondering the performance of STM, how about it vs Unity default text, and can i get any tips to keep things fast? (I'v already read the documents but there is no performance related thing)

Thank you very much!

Developer

Adding performance tips to the documentation is a good idea! I'll make a note of that. For now, I'll say...

Well for mobile games I haven't gotten any mobile performance complaints yet, but knowing the backend of the code, things that could cause a lot of overhead are...

1. If you have a long string of text with an animated effect in it, this can cause extra CPU usage.

2. Setting new text or calling Rebuild() on a long string of text is probably the heaviest method in STM, even after being optimized several times... that said, as long as it's not happening under Update(), you shouldn't see anything.

3. The current outline/dropshadow shaders use a additional passes, so they cause 2x and 8x GPU usage than going without them, respectively. Still, not the worst when it comes down to it, as scary as 8x sounds...

Also, since it's an MMO make sure to look into things like object pooling for the text that pops up when you hit enemies! Having any object cached like that can save you from using Instantiate(), although I hear Unity is apparently more performant at that now, anyway.

Thank you for the tips, it helps.