1 voidUpdate () {2 //determines whether the left mouse button is pressed without pressing the Ugui object3 If (Input.getmousebuttondown (0) &&! EventSystem.current.IsPointerOverGameObject ()) {4 //get a ray from the main camera position to the mouse click position5Ray Ray =Camera.main.ScreenPointToRay (input.mouseposition);6 Raycasthit Hitinfo;7 //bool Iscollider = Physics.raycast (Ray, Out Hitinfo,1000,layermask.nametolayer ("Ground"));8 BOOLIscollider = Physics.raycast (Ray, outhitinfo);9 //Debug.Log (iscollider);Ten //Determine if the ray is successfully launched and whether the target object is triggered One if(Iscollider && HitInfo.collider.tag = ="Ground") { A //parameter is the position information of the target object - Showclickeffect (hitinfo.point); -Ismoving =true; the Lookattarget (hitinfo.point); - //Debug.Log ("007"); - } -}
unity3d--determines whether the mouse triggers the Ugui control