报错
NullReferenceException: Object reference not set to an instance of an object
Enemy.Start () (at Assets/Scripts/Enemy/Enemy.cs:55)
代码
void Start(){
//hudtextGo = GameObject.Instantiate (hudtextPrefab, Vector3.zero, Quaternion.identity) as GameObject;
//hudtextGo.transform.parent = HUDTextParent._instance.gameObject.transform;
hudtextGo = NGUITools.AddChild(HUDTextParent._instance.gameObject, hudtextPrefab);
hudtext = hudtextGo.GetComponent<HUDText>();
followTarget = hudtextGo.GetComponent<UIFollowTarget>();
followTarget.target = hudtextFollow.transform;
followTarget.gameCamera = Camera.main;
print (UICamera.current);
print (UICamera.currentCamera);
followTarget.uiCamera = UICamera.current.GetComponent<Camera>(); //55行
}
unity 4.6 ngui
首先应该不是followTarget的空,因为上面也使用了这个对象没什么问题
所以应该是UICamera.current为空,这个检查下为什么空,或者换别的方式去得到Camera