Esempio n. 1
0
    private static Label Create_Text(Form cForm, string strName, string strText, Rect rcRect, float fFontSize, SpriteText.Anchor_Pos ePso, bool bMultiLine, string strColor)
    {
        Label label = Label.Create(strName, Vector3.zero);

        label.width  = rcRect.width;
        label.height = rcRect.height;
        label.CreateSpriteText();
        label.MaxWidth  = Mathf.Min(rcRect.width, 300f);
        label.MultiLine = true;
        label.ColorText = strColor;
        label.SetCharacterSize(fFontSize);
        SpriteRoot.ANCHOR_METHOD  anchor;
        SpriteText.Alignment_Type alignment;
        switch (ePso)
        {
        case SpriteText.Anchor_Pos.Upper_Left:
        case SpriteText.Anchor_Pos.Middle_Left:
        case SpriteText.Anchor_Pos.Lower_Left:
            anchor    = SpriteRoot.ANCHOR_METHOD.MIDDLE_LEFT;
            alignment = SpriteText.Alignment_Type.Left;
            break;

        case SpriteText.Anchor_Pos.Upper_Center:
        case SpriteText.Anchor_Pos.Middle_Center:
        case SpriteText.Anchor_Pos.Lower_Center:
            anchor    = SpriteRoot.ANCHOR_METHOD.MIDDLE_CENTER;
            alignment = SpriteText.Alignment_Type.Center;
            break;

        case SpriteText.Anchor_Pos.Upper_Right:
        case SpriteText.Anchor_Pos.Middle_Right:
        case SpriteText.Anchor_Pos.Lower_Right:
            anchor    = SpriteRoot.ANCHOR_METHOD.MIDDLE_RIGHT;
            alignment = SpriteText.Alignment_Type.Right;
            break;

        default:
            anchor    = SpriteRoot.ANCHOR_METHOD.MIDDLE_LEFT;
            alignment = SpriteText.Alignment_Type.Left;
            break;
        }
        label.SetAnchor(anchor);
        label.SetAnchor(ePso);
        label.SetAlignment(alignment);
        label.gameObject.renderer.enabled = false;
        label.gameObject.layer            = GUICamera.UILayer;
        label.Text = strText;
        cForm.AddDictionaryControl(strName, label);
        cForm.InteractivePanel.MakeChild(label.gameObject);
        label.SetLocation(rcRect.x, rcRect.y, -0.001f);
        return(label);
    }
Esempio n. 2
0
    private static DrawTexture Create_DrawTexture(Form cForm, string strName, string l_strTexture, Rect rcRect, float Alpha)
    {
        DrawTexture drawTexture = DrawTexture.Create(strName, Vector3.zero);

        drawTexture.width  = rcRect.width;
        drawTexture.height = rcRect.height;
        drawTexture.SetTexture(l_strTexture);
        drawTexture.autoResize = false;
        drawTexture.SetAnchor(SpriteRoot.ANCHOR_METHOD.UPPER_LEFT);
        drawTexture.gameObject.layer = GUICamera.UILayer;
        cForm.AddDictionaryControl(strName, drawTexture);
        cForm.InteractivePanel.MakeChild(drawTexture.gameObject);
        drawTexture.SetLocation(rcRect.x, rcRect.y, -0.001f);
        if (Alpha != 1f)
        {
            Color color = drawTexture.color;
            color.a = Alpha;
            drawTexture.SetColor(color);
        }
        return(drawTexture);
    }