Unity3d 如何在NGUI中获取相机宽度和按钮宽度
我正在尝试访问NGUI 2D UI摄像头的宽度和高度,还尝试访问使用NGUI创建的按钮的宽度和高度。我刚刚想出来Unity3d 如何在NGUI中获取相机宽度和按钮宽度,unity3d,ngui,Unity3d,Ngui,我正在尝试访问NGUI 2D UI摄像头的宽度和高度,还尝试访问使用NGUI创建的按钮的宽度和高度。我刚刚想出来 UIPanel uiPanel = GameObject.Find ("UI Root").GetComponent<UIPanel>(); print(uiPanel.width"); print("uiPanel.height"); UIPanel UIPanel=GameObject.Find(“UI根”).GetComponent(); 打印(uiPanel.
UIPanel uiPanel = GameObject.Find ("UI Root").GetComponent<UIPanel>();
print(uiPanel.width");
print("uiPanel.height");
UIPanel UIPanel=GameObject.Find(“UI根”).GetComponent();
打印(uiPanel.width);
打印(“uiPanel.height”);
另一种方法可以是:
var uiPanel = NGUITools.GetRoot(gameObject).GetComponent<UIPanel>();
print(uiPanel.width");
print("uiPanel.height");
var uiPanel=NGUITools.GetRoot(gameObject.GetComponent();
打印(uiPanel.width);
打印(“uiPanel.height”);
在找到之前,避免在所有场景层次中查找对象。此外,如果您使用多个UICamera,因此使用多个UIRoots,请确保使用正确的UICamera。什么版本的NGUI?我使用的是NGUI v3.5.4r2版本。