Exemple #1
0
    public void setKey(Translations.Key newKey)
    {
        key = newKey;
        string txt = Translations.translateKey(key);

        if (upperCase)
        {
            txt = txt.ToUpper();
        }
        string text     = Translations.wrapText(txt, lineLength);
        float  bgscalex = (Translations.estimateLength(text) + 3) * (GetComponent <TextMesh>().characterSize + 0.5f);

        GetComponent <TextMesh>().text = text;
        if (background != null)
        {
            background.localScale = new Vector3(bgscalex, background.localScale.y, background.localScale.z);
        }

        Vector3 offset = new Vector3();

        if (horizontalAnchorPoint == HorizontalAlignment.LEFT)
        {
            offset.x = -bgscalex / 2;
        }
        else if (horizontalAnchorPoint == HorizontalAlignment.RIGHT)
        {
            offset.x = bgscalex / 2;
        }

        transform.position += offset;
    }
    public void setKey(Translations.Key newKey)
    {
        key = newKey;
        string txt = Translations.translateKey(key);
        if (upperCase) {
            txt = txt.ToUpper();
        }
        string text = Translations.wrapText(txt, lineLength);
        float bgscalex = (Translations.estimateLength(text) + 3) * (GetComponent<TextMesh>().characterSize + 0.5f);
        GetComponent<TextMesh>().text = text;
        if (background != null) {
            background.localScale = new Vector3(bgscalex, background.localScale.y, background.localScale.z);
        }

        Vector3 offset = new Vector3();

        if (horizontalAnchorPoint == HorizontalAlignment.LEFT) {
            offset.x = -bgscalex/2;
        } else if (horizontalAnchorPoint == HorizontalAlignment.RIGHT) {
            offset.x = bgscalex/2;
        }

        transform.position += offset;
    }