public override void Check <T>() { Vector3 mouseCurrentPosition = Input.mousePosition; if (needCheckSpeed && (mouseCurrentPosition - mouseLastPosition).magnitude / Time.deltaTime > MouseSpeedThreshold) { //鼠标过快移动 mouseStopTimeTicker = 0; mouseLastPosition = mouseCurrentPosition; if (currentTarget) { Release(); } return; } else { mouseLastPosition = mouseCurrentPosition; mouseStopTimeTicker += Time.deltaTime; if (mouseStopTimeTicker > DelaySeconds) { mouseStopTimeTicker = 0; Ray ray = Camera.ScreenPointToRay(Input.mousePosition); RaycastHit raycast; Physics.Raycast(ray, out raycast, 10f, Layer); Debug.DrawLine(ray.origin, ray.origin + 10 * ray.direction.normalized, Color.red, 1f); if (raycast.collider != null) { MouseHoverComponent mouseHoverComponent = raycast.collider.gameObject.GetComponent <MouseHoverComponent>(); if (mouseHoverComponent && mouseHoverComponent.GetComponent <T>()) { if (currentTarget && currentTarget != mouseHoverComponent) { Release(); } currentTarget = mouseHoverComponent; currentTarget.IsOnFocus = true; } else { if (currentTarget) { Release(); } } } else { if (currentTarget) { Release(); } } } } }
public override void Check <T>() { if (Input.GetMouseButton(0)) { Ray ray = Camera.ScreenPointToRay(Input.mousePosition); RaycastHit raycast; Physics.Raycast(ray, out raycast, 10f, Layer); Debug.DrawLine(ray.origin, ray.origin + 10 * ray.direction.normalized, Color.yellow); if (raycast.collider != null) { MouseHoverComponent mouseHoverComponent = raycast.collider.gameObject.GetComponent <MouseHoverComponent>(); if (mouseHoverComponent) { if (mouseHoverComponent.GetComponent <T>()) { if (currentTarget && currentTarget != mouseHoverComponent) { Release(); } } currentTarget = mouseHoverComponent; currentTarget.IsOnPressHover = true; } else { if (currentTarget) { Release(); } } } else { if (currentTarget) { Release(); } } } else { if (currentTarget) { Release(); } StateMachine.States curState = Instance.M_StateMachine.GetState(); if (StateMachine.InGameState.Contains(curState) && curState != StateMachine.States.SelectCardWindow_ReadOnly) { Instance.M_StateMachine.SetState(StateMachine.States.BattleNormal); } } }