Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed case where the SceneView don't refresh when using LightExplorer with a running and Paused game (1354129)
- Fixed wrong ordering in FrameSettings (Normalize Reflection Probes)
- Allow negative wind speed parameter.
- Fixed impossibility to release the cursor in the template.

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ public class LookWithMouse : MonoBehaviour
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}

// Update is called once per frame
void Update()
{
bool unlockPressed, lockPressed;

#if ENABLE_INPUT_SYSTEM
float mouseX = 0, mouseY = 0;

Expand All @@ -41,18 +44,38 @@ void Update()
mouseY += value.y;
}

unlockPressed = Keyboard.current.escapeKey.wasPressedThisFrame;
lockPressed = Mouse.current.leftButton.wasPressedThisFrame || Mouse.current.rightButton.wasPressedThisFrame;

mouseX *= mouseSensitivity * k_MouseSensitivityMultiplier;
mouseY *= mouseSensitivity * k_MouseSensitivityMultiplier;
#else
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * k_MouseSensitivityMultiplier;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * k_MouseSensitivityMultiplier;

unlockPressed = Input.GetKeyDown(KeyCode.Escape);
lockPressed = Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1);
#endif

xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
if (unlockPressed)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
if (lockPressed)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}

if (Cursor.lockState == CursorLockMode.Locked)
{
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);

transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);

playerBody.Rotate(Vector3.up * mouseX);
playerBody.Rotate(Vector3.up * mouseX);
}
}
}