문제

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.

도움이 되었습니까?

해결책

I just figure out

UIPanel uiPanel = GameObject.Find ("UI Root").GetComponent<UIPanel>();

print(uiPanel.width");
print("uiPanel.height");

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top