这种行为我不清楚。 在MonoBehaviour中,我有以下代码:
void OnGUI() {
Event e = Event.current;
Vector3 mousePosition = e.mousePosition;
mousePosition.y = Screen.height - mousePosition.y;
Ray ray = cam.ScreenPointToRay(mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo)) {
if (e.rawType == EventType.MouseDown && e.button == 0) {
Debug.Log("DOWN 0");
} else if (e.rawType == EventType.MouseDown && e.button == 1) {
Debug.Log("DOWN 1");
} else if (e.rawType == EventType.MouseDown && e.button == 2) {
Debug.Log("DOWN 2");
} else if (e.rawType == EventType.MouseUp && e.button == 0) {
Debug.Log("UP 0");
} else if (e.rawType == EventType.MouseUp && e.button == 1) {
Debug.Log("UP 1");
} else if (e.rawType == EventType.MouseUp && e.button == 2) {
Debug.Log("UP 2");
}
}
}
所有情况都有效
if (e.rawType == EventType.MouseDown && e.button == 2) {
Debug.Log("DOWN 2");
}
是否存在无法拦截鼠标中键向下的原因?