I am try to access width and height of NGUI 2D UI camera and also try to access width and height of button create with NGUI.
Asked
Active
Viewed 1,794 times
0
-
What version of NGUI? – Bart May 08 '14 at 09:03
-
i am using NGUI v3.5.4r2 version. – Pawan Chaurasiya May 08 '14 at 11:51
2 Answers
0
I just figure out
UIPanel uiPanel = GameObject.Find ("UI Root").GetComponent<UIPanel>();
print(uiPanel.width");
print("uiPanel.height");

Pawan Chaurasiya
- 881
- 2
- 16
- 30
0
Another method could be:
var uiPanel = NGUITools.GetRoot(gameObject).GetComponent<UIPanel>();
print(uiPanel.width");
print("uiPanel.height");
And you avoid looking for the object through all the scene hierarchy until find it. Also, if you are using multiple UICameras and therefore multiple UIRoots you make sure to get the correct one.

Celtc
- 83
- 6