Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Tatanan on December 05, 2014, 07:02:04 AM

Title: UIRoot design width
Post by: Tatanan on December 05, 2014, 07:02:04 AM
After reading several topics in this forum about this, I am figuring out it's not too easy to get the DESIGN width of UI Root.
I mean:
Normally on any widget you just make:
  1. gameObject.GetComponent<UIWidget>().width
and you get the width. But it seems to me this doesn't work for UIRoot. If you make
  1. GameObject("UI Root").GetComponent<UIPanel>().width
you don't get the design width but the screen width (at least width the lastest NGUI version).
I have to multiply this value by
  1. GameObject.Find("UI Root").GetComponent<UIRoot>().manualHeight / Screen.height
So my doubt is:
Is this way to do it? Isn't there any value on UIRoot or UIPanel for the design width?
Title: Re: UIRoot design width
Post by: ArenMook on December 05, 2014, 03:24:29 PM
Screen.width * uiRoot.pixelSizeAdjustment.
Title: Re: UIRoot design width
Post by: Tatanan on December 06, 2014, 10:34:36 AM
Is that value like
  1. uiRoot.manualHeight / Screen.height
?
Title: Re: UIRoot design width
Post by: ArenMook on December 07, 2014, 12:21:22 AM
Not really. Why ask that? Just look at the function. You have the code.
Title: Re: UIRoot design width
Post by: Tatanan on December 09, 2014, 04:32:43 AM
Yes, you're right. Your code is similar to mine but more complete.
About "why ask" is because I wanted to be sure I understood how it worked to avoid problems.
Now it's clear.
Thank you.