Draw Text in OnDrawGizmos

Avatar
  • updated

I want to draw some text in Editor Mode/OnDrawGizmos. After few seconds, console show warning

```

Allocating more than 500 text elements. You are probably leaking and not properly disposing text objects

```

Then it throw error.


Is it right way to draw text?

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator

I'm not sure what your code looks like, but generally drawing in onDrawGizmos can be tricky to get right. make sure you read the immediate mode documentation, especially the part about text drawing. there are a few caveats to be aware of