コード例 #1
0
    void ResizeLabel()
    {
        UILabel label = this.gameObject.GetComponent <UILabel>();

        label.MakePixelPerfect();

        if (useObjectWidth && objectTarget != null)
        {
            int width = (int)objectTarget.localScale.x;
            label.lineWidth = width - offset;
            AuxFunctions.ResizeTextField(label);
        }
        else
        {
            if (label.lineWidth > 0)
            {
                AuxFunctions.ResizeTextField(label);
            }
            else
            {
                float scale = this.transform.localScale.x;
                this.transform.localScale = new Vector3(scale / 2, scale / 2, 0);
            }
        }
    }
コード例 #2
0
 public void ResizeButton()
 {
     if (useChildSize)
     {
         Transform   background = GetComponentInChildren <UISprite>().transform;
         Vector3     tempSize   = background.localScale;
         BoxCollider tempCol    = GetComponent <BoxCollider>();
         if (tempCol)
         {
             tempCol.center = AuxFunctions.GetColliderCenter(background.GetComponent <UISprite>().pivot, tempSize);
             tempCol.size   = tempSize;
         }
         if (resizeText)
         {
             UILabel label = GetComponentInChildren <UILabel>();
             label.transform.localPosition = AuxFunctions.GetColliderCenter(background.GetComponent <UISprite>().pivot, tempSize);
             AuxFunctions.ResizeTextField(label);
         }
         else
         {
             UILabel label = GetComponentInChildren <UILabel>();
             if (label != null)
             {
                 label.transform.localPosition = AuxFunctions.GetColliderCenter(background.GetComponent <UISprite>().pivot, tempSize);
             }
         }
     }
     else
     {
         Vector3     tempSize = Vector3.one;
         BoxCollider tempCol  = GetComponent <BoxCollider>();
         if (tempCol)
         {
             tempCol.center = AuxFunctions.GetColliderCenter(GetComponent <UISprite>().pivot, tempSize);
         }
     }
 }