Beispiel #1
0
    //-----------------------------------------------------
    private void DrawLineLength(Line line, Rect bgRect)
    {
        Vector2 lineCenter = line.GetPixelCenter(bgRect);

        float linePxLen = line.GetPixelLen(bgRect);

        string labelText = (linePxLen * m_mode2D.GetMetersPerPixels()).ToString("F1")+TextManager.GetText("Mode2D.LineLenUnit");
        float rectWidth = m_textStyle.CalcSize(new GUIContent(labelText)).x;
        Rect txtBtnRect = new Rect(0f, 0f, rectWidth, 32f);
        Vector2 rectCenter = new Vector2();
        rectCenter.x = Mathf.Clamp(lineCenter.x, bgRect.x+txtBtnRect.width/2f, bgRect.xMax-txtBtnRect.width/2f);
        rectCenter.y = Mathf.Clamp(lineCenter.y, bgRect.y+txtBtnRect.height/2f, bgRect.yMax-txtBtnRect.height/2f);
        txtBtnRect.center = rectCenter;

        Rect txtBtnRectL = txtBtnRect;
        Rect txtBtnRectR = txtBtnRect;
        Rect txtBtnRectT = txtBtnRect;
        Rect txtBtnRectB = txtBtnRect;
        txtBtnRectL.x -= 1f;
        txtBtnRectR.x += 1f;
        txtBtnRectB.y -= 1f;
        txtBtnRectT.y += 1f;

        GUI.Label(txtBtnRectL, labelText, m_outlineStyle);   // Draw 5 times the text to create a 1px outline
        GUI.Label(txtBtnRectR, labelText, m_outlineStyle);
        GUI.Label(txtBtnRectB, labelText, m_outlineStyle);
        GUI.Label(txtBtnRectT, labelText, m_outlineStyle);
        GUI.Label(txtBtnRect,  labelText, m_textStyle);
    }