iBicha / EmojiTexture

A Unity plugin to render Emojis ☺ ❀ πŸ† πŸ‘ to a texture
Other
62 stars 9 forks source link
android ios texture unity-plugin unity3d

EmojiTexture

:warning: Unity now supports Emojis using TextMesh Pro. Please use that package instead, since this project hasn't been updated for a while.

A Unity plugin to render Emojis ☺ ❀ πŸ† πŸ‘ to a texture. Currently for iOS and Android only.

Please note that the editor is not supported. It will only render on device (should work on simulator as well)

Preview

Usage

As simple as:

material.mainTexture = new EmojiTexture("❀");

You can also do these things:

//Create an EmojiTexture with a specific size (best if power of 2)
var emojiTexture = new EmojiTexture(128);

//Change an existing EmojiTexture
emojiTexture.Text = "❀"; 

//Get the texture as an array of bytes, in case you want to do something with it
var bytes = emojiTexture.ByteBuffer;

//Know the code of the emoji? Set it directly as an integer!
//E.g. https://emojipedia.org/smiling-face-with-smiling-eyes/
emojiTexture.Unicode = 0x1F60A; //😊 Smiling Face With Smiling Eyes

Github emoji API (Experimental)

When not running Android or iOS, EmojiTexture can use Github emoji API. This require network connection. While the list of emojis is cached, individual images are not.

Setting emojis from Github needs to run in a Coroutine, because it is an async operation. It is possible to set the emoji text (same as above)

yield return emojiTexture.SetGithubEmoji("❀");

Or using keywords

yield return emojiTexture.SetGithubEmoji(":heart:");

Please check out example scene for usage (it includes a native emoji, a github emoji and TextMesh Pro examples, that shuffle emojis from script or read user imput with touch screen).

TextMesh Pro support (Experimental)

TextMesh Pro already supports emojis as sprites, but they need to be prepared beforehand, which makes it troublesome in terms of build size (and also a lot of manual work), if you want to support as many emojis as possible. This is where EmojiTexture comes in. It generates these sprites on the fly as they are needed.

Setup

- Import TextMesh Pro from the Asset Store Use the new Package Manager to install TextMesh Pro (this should happen automatically since it is a project dependency)

Scripting Define Symbols

Optimizations

Few pointers to consider:

Known issues.