|
HI all, I have copyed a script from the bbs,and this script is for controlling the texture change. I want to use the mouse click instead of keyborad, so I modified the script a little, but i got an error, "Object reference not set to an instance of an object" Hope for reply.Thanks. The coder is as below:
{ var ray3 = Camera.main.ScreenPointToRay(Input.mousePosition); var hit3 : RaycastHit; if (Physics.Raycast(ray3,hit3) && Input.GetMouseButtonDown(0)) //if(Input.GetKey ("1") ) { var texture:Texture2D = Resources.Load("bed1"); if(texture) { Debug.Log("Texture Loaded Sucessfully..."); renderer.material.mainTexture = texture; } else { Debug.Log("Unable to Load texture..."); } } }
(comments are locked)
|
|
Based on your script, Your "main camera" is the only thing that was not checked and as per what Proclyon mentioned, you have an unassigned object that you're using. Please check that your camera of interest is actually tagged as the "main" camera.
(comments are locked)
|

The error message means you are trying to use something that isn't actually something but just a bunch of reserved memory with nothing in it. Pretty much like an empty cookie jar and a hungry person, it's not gonna work out untill there is something in it. Can you see in the error message what was supposed to be in the jar? It could be a couple of things that's wrong. Also the formatting of the question needs a spit-shine