[Unity] Upgrade to Unity 6.3 LTS#229
Conversation
|
🧱 Stack PR · Base of stack Stack Structure:
|
There was a problem hiding this comment.
Code Review
This pull request upgrades the project to Unity 6000.3.19f1, updates package dependencies, and migrates InputManager.cs to the new Unity Input System. The review feedback highlights two critical issues with the input migration: first, Keyboard.current and Mouse.current can be null, potentially causing NullReferenceExceptions; second, several single-press actions were incorrectly changed to continuous isPressed checks, which will cause them to trigger repeatedly every frame. Adding null checks and using wasPressedThisFrame will resolve these issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (Keyboard.current.tabKey.wasPressedThisFrame) { | ||
| UIManager.Instance.ToggleUIMode(); | ||
| } |
There was a problem hiding this comment.
In Unity's new Input System, Keyboard.current can be null if no keyboard is connected or active (e.g., on mobile devices or during certain startup phases). To prevent a potential NullReferenceException, add a null check before accessing tabKey.
if (Keyboard.current != null && Keyboard.current.tabKey.wasPressedThisFrame) {
UIManager.Instance.ToggleUIMode();
}| var mouse = Mouse.current; | ||
| Vector2 delta = mouse.delta.ReadValue(); | ||
| if (mouse.leftButton.isPressed) { | ||
| CameraController.Instance.OrbitCamera(delta.x, delta.y); | ||
| } else if (mouse.rightButton.isPressed) { | ||
| CameraController.Instance.RotateCamera(delta.x, delta.y); | ||
| } |
There was a problem hiding this comment.
In Unity's new Input System, Mouse.current can be null if no mouse is connected or active. To prevent a potential NullReferenceException, add a null check before accessing its properties.
var mouse = Mouse.current;
if (mouse == null) return;
Vector2 delta = mouse.delta.ReadValue();
if (mouse.leftButton.isPressed) {
CameraController.Instance.OrbitCamera(delta.x, delta.y);
} else if (mouse.rightButton.isPressed) {
CameraController.Instance.RotateCamera(delta.x, delta.y);
}| var mouse = Mouse.current; | ||
| if (mouse.scroll.ReadValue().y != 0) { | ||
| CameraController.Instance.ZoomCamera(mouse.scroll.ReadValue().y * 5); | ||
| } |
There was a problem hiding this comment.
In Unity's new Input System, Mouse.current can be null if no mouse is connected or active. To prevent a potential NullReferenceException, add a null check before accessing its properties.
var mouse = Mouse.current;
if (mouse == null) return;
if (mouse.scroll.ReadValue().y != 0) {
CameraController.Instance.ZoomCamera(mouse.scroll.ReadValue().y * 5);
}| var keyboard = Keyboard.current; | ||
| if (keyboard.leftShiftKey.isPressed) { |
There was a problem hiding this comment.
| var mouse = Mouse.current; | ||
| // Start drag on right mouse button. | ||
| if (Input.GetMouseButtonDown(1)) { | ||
| if (mouse.rightButton.wasPressedThisFrame) { |
There was a problem hiding this comment.
In Unity's new Input System, Mouse.current can be null if no mouse is connected or active. To prevent a potential NullReferenceException, add a null check before accessing its properties.
var mouse = Mouse.current;
if (mouse == null) return;
// Start drag on right mouse button.
if (mouse.rightButton.wasPressedThisFrame) {| var mouse = Mouse.current; | ||
| if (mouse.scroll.ReadValue().y != 0) { | ||
| TacticalPanel.Instance.ZoomIn(mouse.scroll.ReadValue().y * 0.001f); | ||
| } |
There was a problem hiding this comment.
In Unity's new Input System, Mouse.current can be null if no mouse is connected or active. To prevent a potential NullReferenceException, add a null check before accessing its properties.
var mouse = Mouse.current;
if (mouse == null) return;
if (mouse.scroll.ReadValue().y != 0) {
TacticalPanel.Instance.ZoomIn(mouse.scroll.ReadValue().y * 0.001f);
}| var keyboard = Keyboard.current; | ||
| Vector2 keyboardPanDirection = Vector2.zero; | ||
| if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { | ||
| if (keyboard.wKey.isPressed || keyboard.upArrowKey.isPressed) { |
There was a problem hiding this comment.
In Unity's new Input System, Keyboard.current can be null if no keyboard is connected or active. To prevent a potential NullReferenceException, add a null check before accessing its properties.
var keyboard = Keyboard.current;
if (keyboard == null) return;
Vector2 keyboardPanDirection = Vector2.zero;
if (keyboard.wKey.isPressed || keyboard.upArrowKey.isPressed) {| if (keyboard.qKey.isPressed) { | ||
| TacticalPanel.Instance.CycleRangeUp(); | ||
| } | ||
| if (Input.GetKeyDown(KeyCode.E)) { | ||
| if (keyboard.eKey.isPressed) { | ||
| TacticalPanel.Instance.CycleRangeDown(); | ||
| } |
There was a problem hiding this comment.
The old code used Input.GetKeyDown for cycling ranges, which only triggers once per key press. Changing this to isPressed causes the range to cycle rapidly every frame the key is held down. Use wasPressedThisFrame to restore the original behavior.
if (keyboard.qKey.wasPressedThisFrame) {
TacticalPanel.Instance.CycleRangeUp();
}
if (keyboard.eKey.wasPressedThisFrame) {
TacticalPanel.Instance.CycleRangeDown();
}| var keyboard = Keyboard.current; | ||
| if (keyboard.escapeKey.isPressed) { | ||
| SimManager.Instance.QuitSimulation(); | ||
| } | ||
|
|
||
| if (Input.GetKeyDown(KeyCode.R)) { | ||
| if (keyboard.rKey.isPressed) { | ||
| SimManager.Instance.EndSimulation(); | ||
| SimManager.Instance.ResetAndStartSimulation(); | ||
| } | ||
|
|
||
| if (Input.GetKeyDown(KeyCode.L)) { | ||
| if (keyboard.lKey.isPressed) { | ||
| UIManager.Instance.ToggleConfigSelectorPanel(); | ||
| } | ||
|
|
||
| if (Input.GetKeyDown(KeyCode.C)) { | ||
| if (keyboard.cKey.isPressed) { | ||
| ParticleManager.Instance.ClearHitMarkers(); | ||
| } | ||
|
|
||
| if (Input.GetKeyDown(KeyCode.P)) { | ||
| if (keyboard.pKey.isPressed) { | ||
| CameraController.Instance.AutoRotate = !CameraController.Instance.AutoRotate; | ||
| } | ||
|
|
||
| if (Input.GetKeyDown(KeyCode.Space)) { | ||
| if (keyboard.spaceKey.isPressed) { | ||
| // Pause the time. | ||
| if (!SimManager.Instance.IsPaused) { | ||
| SimManager.Instance.PauseSimulation(); |
There was a problem hiding this comment.
There are two critical issues here:
Keyboard.currentcan benullif no keyboard is connected, which will throw aNullReferenceException.- The old code used
Input.GetKeyDownfor these actions, which only triggers once per key press. Changing this toisPressedcauses the actions (like resetting the simulation, toggling panels, etc.) to trigger repeatedly every frame the key is held down. UsewasPressedThisFrameto restore the original behavior.
var keyboard = Keyboard.current;
if (keyboard == null) return;
if (keyboard.escapeKey.wasPressedThisFrame) {
SimManager.Instance.QuitSimulation();
}
if (keyboard.rKey.wasPressedThisFrame) {
SimManager.Instance.EndSimulation();
SimManager.Instance.ResetAndStartSimulation();
}
if (keyboard.lKey.wasPressedThisFrame) {
UIManager.Instance.ToggleConfigSelectorPanel();
}
if (keyboard.cKey.wasPressedThisFrame) {
ParticleManager.Instance.ClearHitMarkers();
}
if (keyboard.pKey.wasPressedThisFrame) {
CameraController.Instance.AutoRotate = !CameraController.Instance.AutoRotate;
}
if (keyboard.spaceKey.wasPressedThisFrame) {
// Pause the time.
if (!SimManager.Instance.IsPaused) {
SimManager.Instance.PauseSimulation();| var keyboard = Keyboard.current; | ||
| if (keyboard[key].wasPressedThisFrame) { | ||
| if (keyboard.leftCtrlKey.isPressed) { | ||
| CameraController.Instance.Follow(followType); |
There was a problem hiding this comment.
In Unity's new Input System, Keyboard.current can be null if no keyboard is connected or active. To prevent a potential NullReferenceException, add a null check before accessing its properties.
var keyboard = Keyboard.current;
if (keyboard == null) return;
if (keyboard[key].wasPressedThisFrame) {
if (keyboard.leftCtrlKey.isPressed) {
CameraController.Instance.Follow(followType);
📝 WalkthroughWalkthroughThis PR migrates Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Assets/Scripts/Managers/InputManager.cs (1)
177-206: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winOne-shot/toggle hotkeys use
isPressed, so they fire every frame the key is held.The legacy code used
Input.GetKeyDown(once per press), but these checks now useisPressed, which is true on every frame the key is held down. This is a functional regression:
rKey.isPressed→EndSimulation()+ResetAndStartSimulation()repeatedly every frame while R is held.lKey/pKey/spaceKey→ panels,AutoRotate, and pause/resume toggle back and forth every frame, causing flicker/flip-flop.escapeKey.isPressed→QuitSimulation()called repeatedly.These are discrete actions and should use
wasPressedThisFrame(consistent withtabKeyon Line 68 and the follow hotkeys on Line 215).🐛 Proposed fix
- if (keyboard.escapeKey.isPressed) { + if (keyboard.escapeKey.wasPressedThisFrame) { SimManager.Instance.QuitSimulation(); } - if (keyboard.rKey.isPressed) { + if (keyboard.rKey.wasPressedThisFrame) { SimManager.Instance.EndSimulation(); SimManager.Instance.ResetAndStartSimulation(); } - if (keyboard.lKey.isPressed) { + if (keyboard.lKey.wasPressedThisFrame) { UIManager.Instance.ToggleConfigSelectorPanel(); } - if (keyboard.cKey.isPressed) { + if (keyboard.cKey.wasPressedThisFrame) { ParticleManager.Instance.ClearHitMarkers(); } - if (keyboard.pKey.isPressed) { + if (keyboard.pKey.wasPressedThisFrame) { CameraController.Instance.AutoRotate = !CameraController.Instance.AutoRotate; } - if (keyboard.spaceKey.isPressed) { + if (keyboard.spaceKey.wasPressedThisFrame) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Assets/Scripts/Managers/InputManager.cs` around lines 177 - 206, The hotkey handling in InputManager uses Keyboard.current with isPressed for discrete actions, which causes repeated firing while a key is held. Update the checks in the input processing block that calls SimManager.Instance.QuitSimulation, EndSimulation, ResetAndStartSimulation, UIManager.Instance.ToggleConfigSelectorPanel, ParticleManager.Instance.ClearHitMarkers, and CameraController.Instance.AutoRotate to use wasPressedThisFrame instead of isPressed. Keep the pause/resume toggle behavior in the same InputManager method so each action triggers once per key press, consistent with the existing tabKey and follow hotkey handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Assets/Scripts/Managers/InputManager.cs`:
- Around line 164-167: `InputManager` is using the continuous `isPressed` state
for the discrete tactical range actions, which causes `CycleRangeUp()` and
`CycleRangeDown()` to fire every frame while Q/E is held. Update the Q and E
handling in `InputManager` to use `wasPressedThisFrame` for those two checks
only, and keep the neighboring movement/panning inputs on `isPressed` since they
are meant to repeat continuously.
---
Outside diff comments:
In `@Assets/Scripts/Managers/InputManager.cs`:
- Around line 177-206: The hotkey handling in InputManager uses Keyboard.current
with isPressed for discrete actions, which causes repeated firing while a key is
held. Update the checks in the input processing block that calls
SimManager.Instance.QuitSimulation, EndSimulation, ResetAndStartSimulation,
UIManager.Instance.ToggleConfigSelectorPanel,
ParticleManager.Instance.ClearHitMarkers, and
CameraController.Instance.AutoRotate to use wasPressedThisFrame instead of
isPressed. Keep the pause/resume toggle behavior in the same InputManager method
so each action triggers once per key press, consistent with the existing tabKey
and follow hotkey handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5cffe517-5c24-4fcd-8d5f-1bbf5273a3dd
⛔ Files ignored due to path filters (10)
Assets/RP/URP Pipepline Asset.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/Settings/Beautiful_PipelineAsset.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/Settings/Fast_PipelineAsset.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/Settings/Fastest_PipelineAsset.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/Settings/Good_PipelineAsset.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/Settings/Simple_PipelineAsset.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/URP.assetis excluded by!**/*.assetAssets/UnityTechnologies/ParticlePack/UniversalRenderPipelineGlobalSettings.assetis excluded by!**/*.assetProjectSettings/GraphicsSettings.assetis excluded by!**/*.assetProjectSettings/ProjectSettings.assetis excluded by!**/*.asset
📒 Files selected for processing (5)
Assets/Scripts/Managers/InputManager.csAssets/Scripts/bamlab.micromissiles.asmdefPackages/manifest.jsonPackages/packages-lock.jsonProjectSettings/ProjectVersion.txt
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
Assets/Scripts/Managers/InputManager.cs (2)
176-206: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse
wasPressedThisFramefor these discrete hotkeys.isPressedmakes pause/resume, reset, toggle, clear, and quit run every frame while the key is held; these should remain one-shot actions like the previousGetKeyDownbehavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Assets/Scripts/Managers/InputManager.cs` around lines 176 - 206, Update HandleNonLockableInput in InputManager so these hotkeys are handled as one-shot actions instead of repeating every frame while held. Replace the Keyboard.current checks for escapeKey, rKey, lKey, cKey, pKey, and spaceKey from isPressed to wasPressedThisFrame so QuitSimulation, EndSimulation/ResetAndStartSimulation, ToggleConfigSelectorPanel, ClearHitMarkers, AutoRotate toggling, and PauseSimulation/ResumeSimulation only fire once per key press.
68-68: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winGuard
Keyboard.current/Mouse.currentbefore polling input.InputManagerdereferences both devices inUpdate()and helper methods without null checks. On headless/CI or any platform where a keyboard or mouse is absent, this can throw in the main update loop. Cache the devices and skip the relevant branch when a device is null.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Assets/Scripts/Managers/InputManager.cs` at line 68, Guard the device polling in InputManager so Update() and the helper methods do not dereference Keyboard.current or Mouse.current when those devices are unavailable. Cache the current keyboard/mouse references at the start of the input flow, null-check them before using fields like tabKey or leftButton, and skip the related branch when a device is missing so headless or CI runs do not throw.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@Assets/Scripts/Managers/InputManager.cs`:
- Around line 176-206: Update HandleNonLockableInput in InputManager so these
hotkeys are handled as one-shot actions instead of repeating every frame while
held. Replace the Keyboard.current checks for escapeKey, rKey, lKey, cKey, pKey,
and spaceKey from isPressed to wasPressedThisFrame so QuitSimulation,
EndSimulation/ResetAndStartSimulation, ToggleConfigSelectorPanel,
ClearHitMarkers, AutoRotate toggling, and PauseSimulation/ResumeSimulation only
fire once per key press.
- Line 68: Guard the device polling in InputManager so Update() and the helper
methods do not dereference Keyboard.current or Mouse.current when those devices
are unavailable. Cache the current keyboard/mouse references at the start of the
input flow, null-check them before using fields like tabKey or leftButton, and
skip the related branch when a device is missing so headless or CI runs do not
throw.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 45896905-2625-49b6-b883-bf22a3ca2b94
📒 Files selected for processing (1)
Assets/Scripts/Managers/InputManager.cs
This PR bumps the Unity editor version to Unity 6.3 (6000.3.19f1). There is a warning that the InputManager is soon to be deprecated, so I have ported over some code to the newer Input System: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.19/manual/Installation.html.