private void Update() { //生成光标射线并处理botton 的接收信息 Physics.Raycast(Camera.main.ScreenPointToRay(eyeCamera.WorldToScreenPoint(cursorParent.position)), out cursorRaycastHit, setting.the可视距离, 1 << LayerMask.NameToLayer("Objects")); Ray temp = Camera.main.ScreenPointToRay(eyeCamera.WorldToScreenPoint(cursorParent.position)); Debug.DrawRay(temp.origin, temp.direction); Botton newActiveBotton = cursorRaycastHit.collider == null ? null : cursorRaycastHit.collider.GetComponent <Botton>(); if (newActiveBotton != currentActiveBotton) { if (currentActiveBotton != null) { currentActiveBotton.OnCursorExit(); } currentActiveBotton = newActiveBotton; if (currentActiveBotton != null) { currentActiveBotton.OnCursorEnter(); } } if (currentActiveBotton != null) { currentActiveBotton.OnCursorOver(); } }