Author Topic: UIRoot design width  (Read 2245 times)

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
UIRoot design width
« 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?
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIRoot design width
« Reply #1 on: December 05, 2014, 03:24:29 PM »
Screen.width * uiRoot.pixelSizeAdjustment.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: UIRoot design width
« Reply #2 on: December 06, 2014, 10:34:36 AM »
Is that value like
  1. uiRoot.manualHeight / Screen.height
?
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIRoot design width
« Reply #3 on: December 07, 2014, 12:21:22 AM »
Not really. Why ask that? Just look at the function. You have the code.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: UIRoot design width
« Reply #4 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.
Game developer on Casual Arena.