-
Notifications
You must be signed in to change notification settings - Fork 228
Clean up editor tools when entering play mode #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up editor tools when entering play mode #157
Conversation
… doesn't stick around in play mode anymore
There was a problem hiding this 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 toEditorToolManagerthat 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.
| foreach ( var tool in ComponentTools ) | ||
| tool?.Dispose(); | ||
| ComponentTools.Clear(); | ||
| previousHash = -1; |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
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.
| foreach ( var tool in ComponentTools ) | |
| tool?.Dispose(); | |
| ComponentTools.Clear(); | |
| previousHash = -1; | |
| try | |
| { | |
| foreach ( var tool in ComponentTools ) | |
| { | |
| tool?.Dispose(); | |
| } | |
| } | |
| finally | |
| { | |
| ComponentTools.Clear(); | |
| previousHash = -1; | |
| } |
There was a problem hiding this comment.
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.
|
This PR has been merged upstream. |
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.