1
\$\begingroup\$

Since it generates more triangles and vertices, the official outline script isn't a good way to do text outlining in my project.

How can I outline my text, with better performance?

TextMesh Pro may be the solution, but it'll increase the usage of memory heavily and our game is aimed at mobile platforms, so we want to minimise use of memory.

\$\endgroup\$
4
  • \$\begingroup\$ I haven’t ever noticed memory problems using Text Mesh Pro on mobile devices. Have you checked? \$\endgroup\$
    – Ed Marty
    Aug 24, 2018 at 11:58
  • \$\begingroup\$ I read a blog last year to talk about the issue. It said if you generate Chinese characters dynamically, it will be a problem. \$\endgroup\$ Aug 25, 2018 at 9:49
  • \$\begingroup\$ Are you using dynamically generated text with outlines? What sort of text? Is it usernames or other text the user can enter? And at what font size? \$\endgroup\$
    – Ed Marty
    Aug 25, 2018 at 15:14
  • \$\begingroup\$ I will use so that will be a problem. I'm considering that make font with outline in Unity, maybe this is a better way rather than others. \$\endgroup\$ Aug 27, 2018 at 2:19

2 Answers 2

1
\$\begingroup\$

There is a very simple way to create outlined text. It's qill be a bit slower theoretically, but I've never come across a situation where an app was running slow because of this.

Let's say we have white text, and we want to outline it in black:

  1. Draw the text in black, slightly offset to the left (1 or 2 pixels should usually suffice).
  2. Do the same thing, but offset to the right.
  3. Repeat steps 1 and 2, but offset the black text up and down.
  4. Draw the white text without an offset.

If you need a very thick outline, and the offset distance increases, you may also want to draw the black text offset diagonally (in 4 directions)

\$\endgroup\$
0
\$\begingroup\$

Not sure if it works on mobile, but maybe this helps https://www.gamedev.net/blogs/entry/2264832-highlight-in-unity/. There are links in there for some other techniques which might suit you better also.

The idea is to have a second camera render the text you want to highlight in solid color, then create a dilated duplicate. Finally, you'd use the non-dilated render as a cutout for the first, effectively creating a solid outline. This outline render would then be passed to your main camera to be used as an 'overlay' RenderTexture.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .