Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Uh, awesome! 

So with this file, downloading this emoji resourced and placing them in my game folder, will make it display the emojis using SuperTextMesh when an emoji is inserted? i mean, lemme explain, when  you copy a normal emoji it and paste, example from here -> https://emojicopy.com/

it displays.

So for what is this code from, it will do automatically, but what i need is to display them in nicknames and titles, example above head.


Whats the best approach?

Yeah, when that extension is set up properly, you would using code like...

superTextMesh.text = "Look at my emoji! 🙂" and what it does is... I have a "preparse" event within SuperTextMesh that it uses, and this event is designed for methods you want to have modify the string after they've been sent to the text mesh, but before the text mesh actually evaluates the string. (This is also great for adding custom tags, check out the "links" example scene for some code with that)

So what it does is turns the above string into something more like "Look at my emoji! <q=emoji1234>" while dynamically creating a quad for the emoji at the same time, so the mesh can render it.


So this would work for you since you're going straight from code. You can just type emoji directly, send it directly to the text mesh, and have it be directly interpreted.

---

When you say "display them in nicknames and titles", do you mean you want to type the emoji more like :smiling: or <q=smiling>...? If that's the case, you can define whatever emoji you want your project to have either in the Text Data editor, or with your custom code you showed me which basically does the same thing to make STMQuadData objects with whatever name you want.

Then, if you don't want to type <q=smiling> and instead something like :smiling: or ":)", you can use the PreParsing event, just like the emoji one I sent to edit your script for you.

e.g. stringToBeSentToMesh = originalString.Replace(":)", "<q=smiling>");

...Like that, but more dynamic!

(5 edits)

Hey! Everything is good but seems some not recognized error thrown:

3 errors on those, why can be those? maybe i am missing OnPreParse and STMTextContainer? i think so, hope you can get me those ones! (I am using unity 5.5.5p2 by the way)


I also did call the method like this, should be okay right? (In Nickname_Controller.cs)


        // Add STMEMoji

        if (gameObject_1.GetComponent<STMEmoji>() == null)

        {

            gameObject_1.AddComponent<STMEmoji>();

        }


Edit: I managed to fix the errors, but after trying to use it like in your example:

        if (text.Contains("Ranger"))

        {

            text = "<c=king><b>" + text + "</b></c> 🙂";

        }


Then, the name dissappears in game after using the emoji, like its not supporting it...maybe i did call it incorrectly?
And yeah, emojis are added:



Modified class:

Pastebin

1. I know you said the issue is resolved, but that could be caused by either an older version of STM, or needing to refresh intellisense in your IDE. Since you're using Unity 5.5.5p2, it's probably that the asset store served you an older version of STM. They don't allow me to upload from Unity 5.3.4 anymore (I still develop in Unity 5.3.4 for maximum compatibility!), so you need to install a more recent version of Unity to get the asset, then move the files to your older project.


2. Honestly the way you're doing this is so baffling to me, and I would just use Unity's inspector to add the component since this is... Unity. Since you're adding a component through code and this is all very customized anyway, what you can do is edit STMEmoji to be a static class, and just subscribe your Super Text Mesh object directly to the "ReplaceEmoji" method, instead of replying on OnEnable and OnDisable to do the subscribing, which may or may not happen in the same frame, and are dependant on script execution order.


3. You didn't follow the steps at the start of the script properly... The folder containing your emoji files *needs* to be named "Resources" (This can be anywhere in your project) so that the Resources.Load() call that happens in the script is able to find them by name. You're welcome to try other methods for grabbing the files without using the Resources folder method, but I couldn't tell you what they are!