Author Topic: How to get the dimensions of UIWidget  (Read 3407 times)

oisy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
How to get the dimensions of UIWidget
« on: January 06, 2014, 01:12:43 AM »
I use a container and creat sprite as its child.
I want to get the size of the container in my script.....

stc105

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: How to get the dimensions of UIWidget
« Reply #1 on: January 06, 2014, 01:53:44 AM »
Size... what do you mean by size (pixels or scale)?

If your "container" is a UIWidget, you can just call the container and look for height and width property:

Script on container:
  1. float height = this.GetComponent<UIWidget>().height;
  2. float width = this.GetComponent<UIWidget>().width;
  3.  

However, the widget is not going to change it's dimensions because you created a sprite as it's child.

If your "container" is just an empty GameObject then there is no size except scale, which is found by looking in the property this.transform.scale


oisy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: How to get the dimensions of UIWidget
« Reply #2 on: January 07, 2014, 03:13:26 AM »
Size... what do you mean by size (pixels or scale)?

If your "container" is a UIWidget, you can just call the container and look for height and width property:

Script on container:
  1. float height = this.GetComponent<UIWidget>().height;
  2. float width = this.GetComponent<UIWidget>().width;
  3.  

However, the widget is not going to change it's dimensions because you created a sprite as it's child.

If your "container" is just an empty GameObject then there is no size except scale, which is found by looking in the property this.transform.scale

Thanks!!!You are so nice!