Skip to content

[Unity] Upgrade to Unity 6.3 LTS#229

Open
tryuan99 wants to merge 2 commits into
masterfrom
titan/unity_6.3
Open

[Unity] Upgrade to Unity 6.3 LTS#229
tryuan99 wants to merge 2 commits into
masterfrom
titan/unity_6.3

Conversation

@tryuan99

@tryuan99 tryuan99 commented Jul 6, 2026

Copy link
Copy Markdown
Member

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.

@tryuan99 tryuan99 requested a review from daniellovell July 6, 2026 04:51
@stacklane-pr-stack-visualizer

Copy link
Copy Markdown

🧱 Stack PR · Base of stack

Stack Structure:

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +68 to 70
if (Keyboard.current.tabKey.wasPressedThisFrame) {
UIManager.Instance.ToggleUIMode();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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();
    }

Comment on lines +74 to 80
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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);
    }

Comment on lines +84 to 87
var mouse = Mouse.current;
if (mouse.scroll.ReadValue().y != 0) {
CameraController.Instance.ZoomCamera(mouse.scroll.ReadValue().y * 5);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);
    }

Comment on lines +91 to +92
var keyboard = Keyboard.current;
if (keyboard.leftShiftKey.isPressed) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.leftShiftKey.isPressed) {

Comment on lines +120 to +122
var mouse = Mouse.current;
// Start drag on right mouse button.
if (Input.GetMouseButtonDown(1)) {
if (mouse.rightButton.wasPressedThisFrame) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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) {

Comment on lines +141 to 144
var mouse = Mouse.current;
if (mouse.scroll.ReadValue().y != 0) {
TacticalPanel.Instance.ZoomIn(mouse.scroll.ReadValue().y * 0.001f);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);
    }

Comment on lines +149 to +151
var keyboard = Keyboard.current;
Vector2 keyboardPanDirection = Vector2.zero;
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) {
if (keyboard.wKey.isPressed || keyboard.upArrowKey.isPressed) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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) {

Comment thread Assets/Scripts/Managers/InputManager.cs Outdated
Comment on lines 164 to 169
if (keyboard.qKey.isPressed) {
TacticalPanel.Instance.CycleRangeUp();
}
if (Input.GetKeyDown(KeyCode.E)) {
if (keyboard.eKey.isPressed) {
TacticalPanel.Instance.CycleRangeDown();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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();
    }

Comment on lines +177 to 202
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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There are two critical issues here:

  1. Keyboard.current can be null if no keyboard is connected, which will throw a NullReferenceException.
  2. The old code used Input.GetKeyDown for these actions, which only triggers once per key press. Changing this to isPressed causes the actions (like resetting the simulation, toggling panels, etc.) to trigger repeatedly every frame the key is held down. Use wasPressedThisFrame to 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();

Comment on lines +214 to 217
var keyboard = Keyboard.current;
if (keyboard[key].wasPressedThisFrame) {
if (keyboard.leftCtrlKey.isPressed) {
CameraController.Instance.Follow(followType);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR migrates InputManager.cs from legacy UnityEngine.Input/KeyCode APIs to UnityEngine.InputSystem for lockable camera controls, tactical input, non-lockable hotkeys, and camera-follow shortcuts, with a matching assembly definition reference. It also bumps the Unity editor version to 6000.3.19f1 and updates Packages/manifest.json and Packages/packages-lock.json with package version changes and new module entries.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: daniellovell

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: upgrading the project to Unity 6.3 LTS.
Description check ✅ Passed The description is directly related and accurately mentions the Unity 6.3 upgrade and Input System migration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch titan/unity_6.3

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

One-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 use isPressed, which is true on every frame the key is held down. This is a functional regression:

  • rKey.isPressedEndSimulation() + 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.isPressedQuitSimulation() called repeatedly.

These are discrete actions and should use wasPressedThisFrame (consistent with tabKey on 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac057d and 53b1a96.

⛔ Files ignored due to path filters (10)
  • Assets/RP/URP Pipepline Asset.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/Settings/Beautiful_PipelineAsset.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/Settings/Fast_PipelineAsset.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/Settings/Fastest_PipelineAsset.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/Settings/Good_PipelineAsset.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/Settings/Simple_PipelineAsset.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/URP.asset is excluded by !**/*.asset
  • Assets/UnityTechnologies/ParticlePack/UniversalRenderPipelineGlobalSettings.asset is excluded by !**/*.asset
  • ProjectSettings/GraphicsSettings.asset is excluded by !**/*.asset
  • ProjectSettings/ProjectSettings.asset is excluded by !**/*.asset
📒 Files selected for processing (5)
  • Assets/Scripts/Managers/InputManager.cs
  • Assets/Scripts/bamlab.micromissiles.asmdef
  • Packages/manifest.json
  • Packages/packages-lock.json
  • ProjectSettings/ProjectVersion.txt

Comment thread Assets/Scripts/Managers/InputManager.cs Outdated
@tryuan99 tryuan99 requested a review from Joseph0120 July 6, 2026 07:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Use wasPressedThisFrame for these discrete hotkeys. isPressed makes pause/resume, reset, toggle, clear, and quit run every frame while the key is held; these should remain one-shot actions like the previous GetKeyDown behavior.

🤖 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 win

Guard Keyboard.current / Mouse.current before polling input. InputManager dereferences both devices in Update() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 53b1a96 and 1986d83.

📒 Files selected for processing (1)
  • Assets/Scripts/Managers/InputManager.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant