iBicha / EmojiTexture

A Unity plugin to render Emojis ☺ ❤ 🍆 🍑 to a texture
Other
62 stars 9 forks source link

Fixing ArgumentOutOfRangeException #19

Closed stopiccot closed 6 years ago

stopiccot commented 6 years ago

Trying to set TextMesh Pro text to "😂⚽️❤️🔥🤪" gives white-squares-instead-of-emoji result and exception in Xcode output:

Parameter name: highSurrogate
  at System.Char.ConvertToUtf32 (Char highSurrogate, Char lowSurrogate) [0x00000] in <filename unknown>:0 
  at iBicha.TMPro.TMProEmojiAsset.Process (System.String text) [0x00000] in <filename unknown>:0 
  at iBicha.TMPro.TMP_EmojiSupport.OnTextChange (System.Object obj) [0x00000] in <filename unknown>:0 
  at TMPro.FastAction`1[A].Call (.A a) [0x00000] in <filename unknown>:0 
  at TMPro.TextMeshProUGUI.GenerateTextMesh () [0x00000] in <filename unknown>:0 
  at TMPro.TextMeshProUGUI.Rebuild (CanvasUpdate update) [0x00000] in <filename unknown>:0 
  at UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () [0x00000] in <filename unknown>:0 
  at UnityEngine.Canvas+WillRenderCanvases.Invoke () [0x00000] in <filename unknown>:0 
UnityEngine.UI.CanvasUpdateRegistry:PerformUpdate()
UnityEngine.WillRenderCanvases:Invoke()

(Filename: currently not available on il2cpp Line: -1)

Trying different ConvertToUtf32() worked fine for me.

iBicha commented 6 years ago

Good catch. The low surrogate is supposed to be the first char, and the high surrogate is supposed to be second, but they were passed incorrectly.

Thank you for your PR