예제 #1
0
    public void GetEmojiInfo(string ketContent, ref EmojiTypeKey type, ref string spriteIndex)
    {
        ketContent = ketContent.Substring(1, ketContent.Length - 2);
        var keys = ketContent.Split(SEPARATOR);

        for (EmojiTypeKey i = 0; i < EmojiTypeKey.COUNT; i++)
        {
            if (i.ToString() == keys[0])
            {
                type = i;
                break;
            }
        }

        spriteIndex = keys[1];
    }
예제 #2
0
        public void SetSize(EmojiTypeKey type, Vector2 size)
        {
            switch (type)
            {
            case EmojiTypeKey.V:
                _videoItem.SetSize(size);
                break;

            case EmojiTypeKey.S:
                _rect.sizeDelta = size;
                break;

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
예제 #3
0
        private Vector2 InitItem(Match match, SpriteItem item)
        {
            string       keyContent = match.Groups[0].Value;
            EmojiTypeKey type       = EmojiTypeKey.S;
            string       id         = "";

            TGConfig.Instance.GetEmojiInfo(keyContent, ref type, ref id);
            Vector2 defaultSize  = Vector2.zero;
            bool    adpativeSize = false;

            switch (type)
            {
            case EmojiTypeKey.V:
                VideoData videoData = TGConfig.Instance.GetVideoData(id);
                item.PlayVideo(videoData.VideoClip);
                defaultSize  = videoData.DefaultSize;
                adpativeSize = videoData.AdaptiveSize;
                break;

            case EmojiTypeKey.S:
                SpriteData spriteData = TGConfig.Instance.GetSpriteData(id);
                item.SetSprite(spriteData.Sprite);
                defaultSize  = spriteData.DefaultSize;
                adpativeSize = spriteData.AdaptiveSize;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (adpativeSize)
            {
                defaultSize = Vector2.one * fontSize;
            }

            item.SetSize(type, defaultSize);

            return(defaultSize);
        }