Draw.Text linebreaks at arbitrary point?

  • updated
  • Fixed

Hi, really enjoying Shapes so far but I'm running into an issue. It's very possible that I'm missing something.

I'm using Immediate Mode rendering for a text element this:

Camera.onPostRender += (Camera cam) => {
                Draw.FontSize = 25;
                Draw.TextAlign = TextAlign.Left;
                Draw.Font = this.font; // Roboto font I imported into my project
                Draw.Text(new Vector3(0, 0, 0), "Hello world and this is a very long string indeed");
        };

This is working mostly as intended. The string shows up in the middle of the screen, however it gets linebroken arbitrarily. What I want is for the string to show up on one line (there are circumstances where I'd want linebreaks but this is not one of them).

Instead what I get is:

Hello world and
this is a very long
string indeed

Clearly it has a "max width" that it's linebreaking against, which is great and all but not what I want in this case. Am I missing something?

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Pinned replies
Freya Holmér
  • Answer
  • Fixed

this is now fixed in 2.3.2

Wyatt Chapman

Did some poking around in the code and I found adding this to Draw.Text fixed the issue.

tmp.enableWordWrapping = false;

So now I have a new question: Was there a cleaner way to do this? Is there any reason why I shouldn't have done this? Thanks!

Freya Holmér
  • Planned

That's very likely the cleanest way to do it! I just forgot to fix this, and the text drawer has a default width which is likely being used here

But I'll get this added to 2.3.2, sorry for the hassle!

Freya Holmér
  • Answer
  • Fixed

this is now fixed in 2.3.2