• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by ratchetunity · Nov 09, 2019 at 04:29 PM · uitextui imagetextmeshhtml5

Display Emojis using its HTML code in a text

Hi!

I was wondering if there is a way to display Emojis in a text using its HTML code (for example, bicycleEmojiCode string is the bicycle emoji in HTML). All I've found uses unicode or other code rather than HTML. This is the code I'm using right now:

 private Text textWithEmoji;
 private const string biclycleEmojiCode = "🚴";

 private void Awake()
 {
     textWithEmoji = GetComponent<Text>();
 }

 private void Start ()
 {
     textWithEmoji.text = biclycleEmojiCode;
 }
Comment

People who like this

0 Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Nov 09, 2019 at 05:45 PM 0
Share

Why would you want HTML codes anyway? I believe you have no choice but create a map (dictionary) HTML → unicode.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Bunny83 · Nov 09, 2019 at 10:25 PM

&#128692; is not an HTML "code". It's actual a SGML / XML / HTML entity reference. Such an entity generally has the form of &XXXX; where XXXX represents the entity name. The special character # denotes a unicode character and the following numbers are simply the decimal unicode code point for the character. Instead of a decimal code point it's usually more common to use hexadecimal code points. For this you generally use &#xHHHH; in XML / HTML where HHHH is a hexadecimal number.


Of course HTML or anything related to HTML is completely irrelevant in Unity. If your used font actually supports your wanted code points you can simply use those unicode characters directly inside your code by using the proper C# unicode escape sequences. In C# you can only specify hexadecimal unicode code points. There are two ways. Either \uXXXX or \UXXXXXXXX Note that when using \u you always have to give exactly 4 hex digits when using \U you have to specify exactly 8 digits. So \u can only be used for the code points 0000 to FFFF.


The code point in question (🚴) is beyond the four digits so you have to use \U. The decimal number "128692" is "1F6B4" in hexadecimal. Since we need 8 digits we have to add 3 padding zeros:

 public const string biclycleEmoji ="\U0001F6B4";


Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ratchetunity · Nov 10, 2019 at 12:43 PM 0
Share

Hi @Bunny83 thanks for the answers, I really appreciate it. I've tried using \U0001F6B4 but it always show a ? mark inside a diamond. Do you know how to solve that issue? I've Rich Text enabled and have tried different fonts that are supposed to support emoji, but doesn't seem to work :(

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

203 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UI components all disappear on Play mode, then stay invisible 2 Answers

TextMeshPro mask not working 1 Answer

add and remove matches 0 Answers

Line limit in ui text or text mesh pro 0 Answers

Remove characters from string from start to finish 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges