예제 #1
0
        void DrawLabel()
        {
            // Exit if label layout not defined
            if (labelLayout.glyphLayout == null || labelLayout.glyphLayout.Length == 0)
            {
                return;
            }

            // Set render area
            Material material    = font.GetMaterial();
            Vector4  scissorRect = (useRestrictedRenderArea) ? GetRestrictedRenderScissorRect() : new Vector4(0, 1, 0, 1);

            material.SetVector("_ScissorRect", scissorRect);

            // Draw glyphs with classic layout
            Rect totalRect = Rectangle;

            for (int i = 0; i < labelLayout.glyphLayout.Length; i++)
            {
                GlyphLayoutData glyphLayout = labelLayout.glyphLayout[i];

                Rect targetRect = new Rect(
                    totalRect.x + glyphLayout.x * LocalScale.x * textScale + HorzPixelScrollOffset * LocalScale.x * textScale,
                    totalRect.y + glyphLayout.y * LocalScale.y * textScale,
                    glyphLayout.glyphWidth * LocalScale.x * textScale,
                    font.GlyphHeight * LocalScale.y * textScale);

                font.DrawClassicGlyph(glyphLayout.glyphRawAscii, targetRect, textColor, shadowPosition * LocalScale, shadowColor);
            }
        }
예제 #2
0
        public override void Draw()
        {
            if (!Enabled)
            {
                return;
            }

            if (drawToolTip)
            {
                base.Draw();

                // Set render area for tooltip to whole screen (material might have been changed by other component, i.e. _ScissorRect might have been set to a subarea of screen (e.g. by TextLabel class))
                Material material    = font.GetMaterial();
                Vector4  scissorRect = new Vector4(0, 1, 0, 1);
                material.SetVector("_ScissorRect", scissorRect);

                // Determine text position
                Rect    rect    = Rectangle;
                Vector2 textPos = new Vector2(
                    rect.x + LeftMargin * LocalScale.x,
                    rect.y + TopMargin * LocalScale.y);

                //if (rect.xMax > Screen.width) textPos.x -= (rect.xMax - Screen.width);

                // Draw tooltip text
                for (int i = 0; i < textRows.Length; i++)
                {
                    font.DrawText(textRows[i], textPos, LocalScale, textColor);
                    textPos.y += font.GlyphHeight * LocalScale.y;
                }

                // Lower flag
                drawToolTip = false;
            }
        }
예제 #3
0
        void DrawLabel()
        {
            // Exit if no layout
            if (glyphLayout.Count == 0)
            {
                return;
            }

            // Set render area
            Material material    = font.GetMaterial();
            Vector4  scissorRect = (UseRestrictedRenderArea) ? GetRestrictedRenderScissorRect() : new Vector4(0, 1, 0, 1);

            material.SetVector("_ScissorRect", scissorRect);

            // Draw glyphs with classic layout
            if (!font.IsSDFCapable)
            {
                Rect totalRect = Rectangle;
                for (int i = 0; i < glyphLayout.Count; i++)
                {
                    GlyphLayoutData glyph = glyphLayout[i];

                    Rect targetRect = new Rect(
                        totalRect.x + glyph.x * LocalScale.x * textScale + HorzPixelScrollOffset * LocalScale.x * textScale,
                        totalRect.y + glyph.y * LocalScale.y * textScale,
                        glyph.width * LocalScale.x * textScale,
                        font.GlyphHeight * LocalScale.y * textScale);

                    font.DrawClassicGlyph((byte)glyph.code, targetRect, textColor, shadowPosition * LocalScale, shadowColor);
                }
            }
            else
            {
                Rect totalRect = Rectangle;
                for (int i = 0; i < glyphLayout.Count; i++)
                {
                    GlyphLayoutData glyph = glyphLayout[i];

                    Vector2 position = new Vector2(
                        totalRect.x + glyph.x * LocalScale.x * textScale + HorzPixelScrollOffset * LocalScale.x * textScale,
                        totalRect.y + glyph.y * LocalScale.y * textScale);

                    font.DrawSDFGlyph(glyph.code, position, LocalScale * textScale, textColor, shadowPosition * LocalScale, shadowColor);
                }
            }
        }
        void DrawLabel()
        {
            // Exit if label layout not defined
            if (labelLayout.glyphLayout == null || labelLayout.glyphLayout.Length == 0)
            {
                return;
            }

            // Set render area
            Material material    = font.GetMaterial();
            Vector4  scissorRect = (useRestrictedRenderArea) ? GetRestrictedRenderScissorRect() : new Vector4(0, 1, 0, 1);

            material.SetVector("_ScissorRect", scissorRect);

            // Layout glyphs
            Rect totalRect = Rectangle;

            for (int i = 0; i < labelLayout.glyphLayout.Length; i++)
            {
                GlyphLayoutData glyphLayout = labelLayout.glyphLayout[i];

                Rect targetRect = new Rect(
                    totalRect.x + glyphLayout.x * LocalScale.x * textScale + HorzPixelScrollOffset * LocalScale.x * textScale,
                    totalRect.y + glyphLayout.y * LocalScale.y * textScale,
                    glyphLayout.glyphWidth * LocalScale.x * textScale,
                    font.GlyphHeight * LocalScale.y * textScale);

                // Allow SDF glyph to draw into the "single pixel" empty space normally reserved for classic letter spacing
                // As SDF fonts are so much more detailed, this single pixel space ends up looking very large and unnecessary
                // This has the effect of keeping glyphs a bit closer together while using the exact screen rect allowed
                if (font.IsSDFCapable)
                {
                    targetRect.width += font.GlyphSpacing * LocalScale.x * textScale;
                }

                font.DrawGlyph(glyphLayout.glyphRawAscii, targetRect, textColor, shadowPosition * LocalScale, shadowColor);
            }
        }