Example #1
0
        // Store Vertex Information for each Sprite
        void SaveSpriteVertexInfo(Color32 vertexColor)
        {
            //int padding = m_enableExtraPadding ? 4 : 0;
            // Determine UV for the Sprite
            Vector2 uv0 = new Vector2(m_cached_GlyphInfo.x / m_inlineGraphics.spriteAsset.spriteSheet.width, m_cached_GlyphInfo.y / m_inlineGraphics.spriteAsset.spriteSheet.height);  // bottom left
            Vector2 uv1 = new Vector2(uv0.x, (m_cached_GlyphInfo.y + m_cached_GlyphInfo.height) / m_inlineGraphics.spriteAsset.spriteSheet.height);  // top left
            Vector2 uv2 = new Vector2((m_cached_GlyphInfo.x + m_cached_GlyphInfo.width) / m_inlineGraphics.spriteAsset.spriteSheet.width, uv0.y); // bottom right
            Vector2 uv3 = new Vector2(uv2.x, uv1.y); // top right


            // Vertex Color Alpha
            Color32 spriteColor = Color.white; 
            spriteColor.a = m_fontColor32.a < vertexColor.a ? m_fontColor32.a : vertexColor.a;

            TMP_Vertex vertex = new TMP_Vertex();
            // Bottom Left Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].bottomLeft;
            vertex.uv = uv0;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_BL = vertex;
            
            // Top Left Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].topLeft;
            vertex.uv = uv1;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_TL = vertex;
            
            // Top Right Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].topRight;
            vertex.uv = uv3;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_TR = vertex;
            
            // Bottom Right Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].bottomRight;
            vertex.uv = uv2;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_BR = vertex;
        }
Example #2
0
        /// <summary>
        /// Store Vertex Information for each Sprite
        /// </summary>
        /// <param name="vertexColor"></param>
        protected override void SaveSpriteVertexInfo(Color32 vertexColor)
        {
            //int padding = m_enableExtraPadding ? 4 : 0;
            // Determine UV for the Sprite
            Vector2 uv0 = new Vector2(m_cached_TextElement.x / m_inlineGraphics.spriteAsset.spriteSheet.width, m_cached_TextElement.y / m_inlineGraphics.spriteAsset.spriteSheet.height);  // bottom left
            Vector2 uv1 = new Vector2(uv0.x, (m_cached_TextElement.y + m_cached_TextElement.height) / m_inlineGraphics.spriteAsset.spriteSheet.height);  // top left
            Vector2 uv2 = new Vector2((m_cached_TextElement.x + m_cached_TextElement.width) / m_inlineGraphics.spriteAsset.spriteSheet.width, uv0.y); // bottom right
            Vector2 uv3 = new Vector2(uv2.x, uv1.y); // top right


            // Vertex Color Alpha
            if (m_tintAllSprites) m_tintSprite = true;
            Color32 spriteColor = m_tintSprite ? m_spriteColor.Multiply(vertexColor) : m_spriteColor;
            spriteColor.a = spriteColor.a < m_fontColor32.a ? spriteColor.a = spriteColor.a < vertexColor.a ? spriteColor.a : vertexColor.a : m_fontColor32.a; 

            TMP_Vertex vertex = new TMP_Vertex();
            // Bottom Left Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].bottomLeft;
            vertex.uv = uv0;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_BL = vertex;
            
            // Top Left Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].topLeft;
            vertex.uv = uv1;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_TL = vertex;
            
            // Top Right Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].topRight;
            vertex.uv = uv3;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_TR = vertex;
            
            // Bottom Right Vertex
            vertex.position = m_textInfo.characterInfo[m_characterCount].bottomRight;
            vertex.uv = uv2;
            vertex.color = spriteColor;
            m_textInfo.characterInfo[m_characterCount].vertex_BR = vertex;
        }