Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: oisy on January 06, 2014, 01:12:43 AM

Title: How to get the dimensions of UIWidget
Post by: oisy 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.....
Title: Re: How to get the dimensions of UIWidget
Post by: stc105 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

Title: Re: How to get the dimensions of UIWidget
Post by: oisy 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!