-1
我得到這個代碼的NullReferenceException
if (Input.GetMouseButton(0)){
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
......
}`
它與我創建的其他項目,但是當我試圖實現它與我的新項目,它返回一個NullReferenceException。
NullReferenceException
UnityEngine.Camera.ScreenPointToRay (Vector3 position) (at C:/BuildAgent/work/300357e52574df36/Runtime/ExportGenerated/Editor/UnityEngineCamera.cs:276)
Ball.Update() (at Assets/Scripts/Ball.js:51)`
錯誤指向這一部分VAR光= Camera.main ..... 我試圖與場景中添加光但它仍然不工作。 請告訴我什麼是解決方案。通過整個代碼打算移動或拖動對象/球的方式。
可能重複[什麼是NullReferenceException,我該如何解決它?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-doi-i-fix-它) – LearnCocos2D