Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miguel12345/UnityTextDrawer
Draw beautiful 3D texts with one line of code.
https://github.com/miguel12345/UnityTextDrawer
Last synced: 3 months ago
JSON representation
Draw beautiful 3D texts with one line of code.
- Host: GitHub
- URL: https://github.com/miguel12345/UnityTextDrawer
- Owner: miguel12345
- License: mit
- Created: 2017-07-16T10:00:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-04T23:02:58.000Z (almost 7 years ago)
- Last Synced: 2024-07-14T13:36:12.497Z (4 months ago)
- Language: C#
- Size: 18.7 MB
- Stars: 47
- Watchers: 6
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-unity-open-source-on-github - UnityTextDrawer - Draw beautiful 3D texts with one line of code (Script Utility)
README
# TextDrawer
Draw beautiful 3D texts with one line of code. It's like `Graphics.DrawMesh`, but for text
![](readme.gif)
## Features!
+ Supports custom fonts
+ Supports multiple font sizes
+ Super Fast!
+ 0 GC alloc once the cache is filled
+ Supports outlining, bevel, glow and all other [TextMeshPro](https://www.assetstore.unity3d.com/en/#!/content/84126) features
+ *NEW*: Custom pivots
![](text_drawer_pivot.gif)## The problem
You know those times when you just want to draw a text on the screen for a short duration, or you want to draw multiple similar texts, but you don't want to go through the hassle of creating/updating/removing game objecs and mono behaviours for such a simple purpose?`TextDrawer` is here to solve that!
## The solution
`TextDrawer` uses [TextMeshPro](https://www.assetstore.unity3d.com/en/#!/content/84126) as its backend text mesh generator, and manages an internal *LRU* cache to save the previously created meshes. When you want to draw a 3D text in the current frame, just invoke `TextDrawer.DrawText(string text,float fontSize,Color color,Matrix4x4 mat)`.
NOTE: By default, TextDrawer's internal cache holds 400 items at the same time. If you are planning on drawing more than 400 different strings per frame, please increase the cache size through `TextDrawer.CacheCapacity`.
## Instructions
+ Import the `packages/UnityTextDrawer.unitypackage` to your project
+ If you already have TextMeshPro, deselect it from the import window
+ Add a line of code! (see example below)
+ If you want to use custom fonts, just use `TextMeshPro`'s Create Font asset feature and pass in the resulting font asset to the draw method## Example
```CSharp
public class TextDrawerTest : MonoBehaviour
{
public int ShowText;
void Update() {
if(ShowText) {
TextDrawer.DrawText("Hello!",12f,Color.white,Matrix4x4.TRS(Vector3.zero,Quaternion.Identity,Vector3.one);
}
}
}```