static bool GetIndex_(EmojiConfig config, string ch, out int ind) { if (getIndexDelegate == null) { return(GetIndex(config, ch, out ind)); } return(getIndexDelegate(config, ch, out ind)); }
static Rect GetRect_(EmojiConfig config, int ind) { if (getRectDelegate == null) { return(GetRect(config, ind)); } return(getRectDelegate(config, ind)); }
static Texture GetTexture_(EmojiConfig config) { if (getTextureDelegate == null) { return(GetTexture(config)); } return(getTextureDelegate(config)); }
public static void UpdateEmojiReplacements(string inputString, EmojiConfig config, System.Action <string, int> onEmojiChar) { if (!string.IsNullOrEmpty(inputString)) { int i = 0; while (i < inputString.Length) { string singleChar = inputString.Substring(i, 1); string doubleChar = ""; string fourChar = ""; if (i < (inputString.Length - 1)) { doubleChar = inputString.Substring(i, 2); } if (i < (inputString.Length - 3)) { fourChar = inputString.Substring(i, 4); } int emojiIndex; if (GetIndex_(config, fourChar, out emojiIndex)) { // Check 64 bit emojis first onEmojiChar(fourChar, emojiIndex); i += 4; } else if (GetIndex_(config, doubleChar, out emojiIndex)) { // Then check 32 bit emojis onEmojiChar(doubleChar, emojiIndex); i += 2; } else if (GetIndex_(config, singleChar, out emojiIndex)) { onEmojiChar(singleChar, emojiIndex); i++; } else { onEmojiChar(singleChar, -1); i++; } } } }
protected static bool GetIndex(EmojiConfig config, string ch, out int ind) { return(config.map.TryGetValue(ch, out ind)); }
protected static Rect GetRect(EmojiConfig config, int ind) { return(config.rects[ind]); }
protected static Texture GetTexture(EmojiConfig config) { return(config.texture); }