// Update is called once per frame void Update() { #region for test if (Input.GetKeyDown(KeyCode.P)) { PickSingleItem(); } if (Input.GetKeyDown(KeyCode.A)) { PickSurroundingItems(); } Debug.DrawRay(tr.position, tr.forward * rayLength, Color.green); #endregion if (raycastSingle && Physics.Raycast(tr.position, tr.forward, out hit, rayLength, mask.value)) { //Debug.Log ("射线击中:" + hit.collider.gameObject.name + "\n tag:" + hit.collider.tag); GameObject gameObj = hit.collider.gameObject; if (gameObj != gazingItemLastFrame) { if (gazingItemLastFrame != null) { ToolItem item = gazingItemLastFrame.GetComponent <ToolItem>(); if (item != null) { item.OnGazeEnd(); } } if (gameObj != null) { ToolItem item = gameObj.GetComponent <ToolItem>(); if (item != null) { item.OnGazeStart(); } } gazingItemLastFrame = gameObj; } } else { //Debug.Log("射线没击中"); } }