Exemplo n.º 1
0
    public override void SetVerticesDirty()
    {
        base.SetVerticesDirty();

        //解析超链接
        m_OutputText = GetOutputText();


        //解析标签属性
        listTagInfor   = new List <SpriteTagInfor>();
        m_AnimIndex    = new List <int>();
        m_AnimSpiteTag = new Dictionary <int, SpriteTagInfor[]>();

        foreach (Match match in m_spriteTagRegex.Matches(m_OutputText))
        {
            if (m_spriteAsset == null)
            {
                return;
            }

            #region 解析动画标签
            List <string> tempListName = new List <string>();
            for (int i = 0; i < m_spriteAsset.listSpriteInfor.Count; i++)
            {
                // Debug.Log((m_spriteAsset.listSpriteInfor[i].name));
                if (m_spriteAsset.listSpriteInfor[i].name.Contains(match.Groups[1].Value))
                {
                    tempListName.Add(m_spriteAsset.listSpriteInfor[i].name);
                }
            }
            if (tempListName.Count > 0)
            {
                SpriteTagInfor[] tempArrayTag = new SpriteTagInfor[tempListName.Count];
                for (int i = 0; i < tempArrayTag.Length; i++)
                {
                    tempArrayTag[i]        = new SpriteTagInfor();
                    tempArrayTag[i].name   = tempListName[i];
                    tempArrayTag[i].index  = match.Index;
                    tempArrayTag[i].size   = new Vector2(float.Parse(match.Groups[2].Value) * float.Parse(match.Groups[3].Value), float.Parse(match.Groups[2].Value));
                    tempArrayTag[i].Length = match.Length;
                }
                listTagInfor.Add(tempArrayTag[0]);
                m_AnimSpiteTag.Add(listTagInfor.Count - 1, tempArrayTag);
                m_AnimIndex.Add(listTagInfor.Count - 1);
            }
            #endregion
        }
        Vector2 extents = rectTransform.rect.size;
    }
Exemplo n.º 2
0
    /// <summary>
    /// 解析动画标签
    /// </summary>
    protected void MatchEmojiRichText()
    {
        MatchCollection spriteTagMatchCollection = m_spriteTagRegex.Matches(m_OutputText);
        int             matchLength = 0;

        foreach (Match match in spriteTagMatchCollection)
        {
            List <string> tempListName = new List <string>();
            for (int i = 0, len = m_spriteAsset.listSpriteInfor.Count; i < len; i++)
            {
                // Debug.Log((m_spriteAsset.listSpriteInfor[i].name));
                if (m_spriteAsset.listSpriteInfor[i].name.StartsWith(match.Groups[1].Value))
                {
                    tempListName.Add(m_spriteAsset.listSpriteInfor[i].name);
                }
            }
            if (tempListName.Count > 0)
            {
                float size  = float.Parse(match.Groups[2].Value);
                float width = float.Parse(match.Groups[3].Value);
                if (size <= 0f)
                {
                    size = this.fontSize;
                }
                if (width <= 0f)
                {
                    width = 1;
                }
                int sLength = tempListName.Count;
                TList <SpriteTagInfor> spriteTagInfor = new TList <SpriteTagInfor>();
                for (int i = 0; i < sLength; i++)
                {
                    SpriteTagInfor tempSpriteTag = new SpriteTagInfor();
                    tempSpriteTag.name   = tempListName[i];
                    tempSpriteTag.index  = match.Index;
                    tempSpriteTag.size   = new Vector2(size * width, size);
                    tempSpriteTag.Length = match.Length;
                    spriteTagInfor.Add(tempSpriteTag);
                }
                //listTagInfor.Add(tempArrayTag[0]);
                m_AnimSpiteTag.Add(spriteTagInfor);
                mEmojiIndexList.Add(m_AnimSpiteTag.Count - 1);
            }

            matchLength += match.Length;
        }
        mRichTextParams[1] = spriteTagMatchCollection.Count;
        mRichTextParams[0] = mRichTextParams[0] - matchLength + mRichTextParams[1];
    }