Skip to content

Conversation

@boxrocket6803
Copy link

When entering play mode editor tools would stop updating but wouldn't be deleted, leaving them in a non-functional state taking up space on the screen (specifically camera preview and the particle controls). This disposes of editor tools when entering play mode so any connected widgets can be properly removed. Upon exiting play mode or ejecting the editor tools reappear.

@handsomematt handsomematt requested a review from Copilot January 12, 2026 18:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a bug where editor tools (camera preview and particle controls) would remain visible but non-functional when entering play mode. The fix introduces a cleanup mechanism to properly dispose of editor tools when entering play mode, with tools reappearing when exiting play mode or ejecting.

Changes:

  • Added a ClearScreen() method to EditorToolManager that disposes of all component tools and resets internal state
  • Integrated the cleanup by calling ClearScreen() when transitioning to game view and when possessing the game

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
game/addons/tools/Code/Scene/Tools/EditorToolManager.cs Implements the ClearScreen() method to dispose of editor tools and clear state
game/addons/tools/Code/Scene/SceneView/SceneViewportWidget.Game.cs Calls ClearScreen() during game view transitions to clean up editor tools

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 193 to 196
foreach ( var tool in ComponentTools )
tool?.Dispose();
ComponentTools.Clear();
previousHash = -1;
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The clearing of ComponentTools after disposing could leave the collection in an inconsistent state if any Dispose() call throws an exception. Consider wrapping the disposal in a try-catch block or using a finally block to ensure ComponentTools.Clear() always executes.

Suggested change
foreach ( var tool in ComponentTools )
tool?.Dispose();
ComponentTools.Clear();
previousHash = -1;
try
{
foreach ( var tool in ComponentTools )
{
tool?.Dispose();
}
}
finally
{
ComponentTools.Clear();
previousHash = -1;
}

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

dispose is used similarly elsewhere in same file, dispose doesn't have any good reason to be throwing exceptions, wont cause any lasting damage if component tools doesnt get cleared. Doesn't seem like something to lose sleep over.

@handsomematt handsomematt added the triaged triaged pull-requests are replicated on the internal sbox repo label Jan 15, 2026
@sboxbot sboxbot added the accepted this pull request was accepted, hurrah! label Jan 15, 2026
@sboxbot
Copy link
Contributor

sboxbot commented Jan 15, 2026

This PR has been merged upstream.

@sboxbot sboxbot closed this Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted this pull request was accepted, hurrah! triaged triaged pull-requests are replicated on the internal sbox repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants