Пример #1
0
    // Calculates the clipping rect for the text
    public void CalcClippingRect()
    {
        if (spriteText == null)
        {
            return;
        }

        Vector3 tl = marginTopLeft;
        Vector3 br = marginBottomRight;

        // Clamp the client rect to any clipping rect we may have:
        if (clipped)
        {
            Vector3 origTL = tl;
            Vector3 origBR = br;
            tl.x = Mathf.Clamp(localClipRect.x, origTL.x, origBR.x);
            br.x = Mathf.Clamp(localClipRect.xMax, origTL.x, origBR.x);
            tl.y = Mathf.Clamp(localClipRect.yMax, origBR.y, origTL.y);
            br.y = Mathf.Clamp(localClipRect.y, origBR.y, origTL.y);
        }

        clientClippingRect.FromRect(Rect.MinMaxRect(tl.x, br.y, br.x, tl.y));
        clientClippingRect.MultFast(transform.localToWorldMatrix);

        spriteText.ClippingRect = clientClippingRect;
        if (caret != null)
        {
            caret.ClippingRect = clientClippingRect;
        }
    }
Пример #2
0
 public virtual void SetClippingRect(Rect3D value)
 {
     if (this.ignoreClipping)
     {
         return;
     }
     this.clippingRect  = value;
     this.localClipRect = Rect3D.MultFast(this.clippingRect, base.transform.worldToLocalMatrix).GetRect();
     if (this.localClipRect.width < 0f)
     {
         this.localClipRect.width = -this.localClipRect.width;
         this.localClipRect.x     = this.localClipRect.x - this.localClipRect.width;
     }
     this.clipped = true;
     this.CalcSize();
     this.UpdateUVs();
 }