-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Embed game process in editor #99010
Embed game process in editor #99010
Conversation
8aa3953
to
e6bdeae
Compare
e6bdeae
to
9b9207e
Compare
Add |
Is this a limitation? If not, you could embed multiple instances inside a TabContainer. EDIT: |
This comment was marked as resolved.
This comment was marked as resolved.
9b9207e
to
abeae2c
Compare
I added "embedded" to |
abeae2c
to
c34b874
Compare
Someone linked me this recent Bluesky post: https://bsky.app/profile/akien.bsky.social/post/3lckoohfoms2q
Is there a specific contributor actively working on this for now, or is this just meant to say "someone will work on it soon hopefully"? If the former, is there a place where I can watch progress? |
See the above comment by @bruvzg, who's maintaining the macOS platform:
|
Ah alrighty, thanks! I'd seen that comment previously, and interpreted it as more of a "it'll happen sometime by someone, but these are the hurdles they'd have to overcome from my knowledge/experience" than an explicit "I'll be working on it soon". |
Hey there, thanks for the amazing work! I just wanted to ask if this could make it to the next dev release? |
@Hilderin This will need another rebase. |
1706e21
to
0fe5317
Compare
There you go... Rebase done!! |
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.
I get this when switching to the "Game" tab:
E 0:00:00:0127 window_set_position: Embedded window can't be moved.
<C++ Error> Condition "wd.embed_parent" is true.
<C++ Source> platform/linuxbsd/x11/display_server_x11.cpp:2265 @ window_set_position()
Fedora GNU/Linux 41 (XWayland).
I'm unable to reproduce this error. I tested on Fedora and Ubuntu. Can you share a MRP and explain with a bit more details how to reproduce the error? Thanks. |
0fe5317
to
49b8034
Compare
I can reproduce it even with a fresh empty project, not doing anything special. |
It works fine for me on archlinux/KDE (xwayland) 🤔 |
Can you share your editor settings file, maybe you have a setting that was not tested/expected. |
49b8034
to
d968302
Compare
@YeldhamDev |
Sorry for the late response, was tangled in something else. Could you rebase? |
Fantastic work! I'd really love to see this in Godot 4.4. I hope there will be another dev snapshot. |
d968302
to
9d2a4c0
Compare
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.
No errors on my end now, good job! I think there are still some stuff that could use some polish, but nothing deal breaking. LGTM.
Thanks for the amazing work @Hilderin, this complements the new Game tab very well! |
@akien-mga / @bruvzg OpenEmu does what you describe for macOS, as it spawns a child XPC process, and uses a remote layer (the Metal / Vulkan frame buffer), to display in the parent process, which is the most efficient. WebKit does this, by running subprocesses for the browser engine and displaying them all in a single, parent process. I might take a look at that, if no one else is. |
Implements game embedding for Windows and Linux (X11 only) in the new Game Workspace: GitHub PR #97257
As suggested, this implementation places the running game window as a child of the editor and embeds it inside the Game Workspace. The running game remains a separate process, with all keys and inputs handled in a separate event loop to maintain performance even when embedded.
U7w7iZ8zil.mp4
New Options in the Game Workspace Toolbar
Embed game on Next Play: On/Off: Enables or disables embedding the next time the game is started. (Default: Enabled)
Make Game Workspace floating on Next Play: On/Off: When enabled, the Game Workspace opens in a floating window when the game starts. (Default: Enabled)
Keep the aspect ratio of the embedded game: On/Off: Maintains the aspect ratio of the game window in the Game Workspace while embedding is enabled. (Default: Enabled)
Important Information
Additional Features
Engine.is_embedded_in_editor()
method in GDScript/C#, which helps prevent errors when attempting to change unsupported window settings while embedded or for adjusting behavior based on whether embedding is active.OS.has_feature("embedded_in_editor")
.Making Your Game "Embedded-Compatible"
Handling Mouse Capture: Currently, no default keyboard shortcut exists to exit mouse capture mode when embedded, which can be inconvenient for games like the TPS Demo that hide the mouse cursor during gameplay. As a workaround, you can modify the game to toggle the mouse cursor on pressing the Escape key instead of returning to the menu. Here’s an example for
level.gd
:Preventing Fullscreen Errors: In the TPS Demo, errors occur when starting the game in fullscreen mode while embedded, as the
DisplayServer
does not allow window mode changes in embedded mode. You can prevent these errors using a simple check:Known Issues
Windows: If the user focuses on the embedded game and quickly clicks a button in the editor, the click may not register. This seems to be due to Windows taking too long to reactivate the editor window, causing the mouse-up event to be missed. Disabling
Unfocused Low Power Mode
while the game is embedded mitigates this issue but is not a perfect solution.Linux: X11 does not support moving windows outside screen bounds. If the editor window is moved outside the screen boundaries while embedding a game, the window is resized to prevent Linux from resetting its position to the screen edge. This limitation appears to be a known issue without a programmatic workaround.
Scene Previews Disabled: When the Game Workspace tab is active, scene previews are disabled because they appear under the embedded game. Since previews are standard controls rather than popups, this is a temporary workaround to prevent issues, though it disables scene previews. Addressing this in a future PR is recommended.
Game Process Recording: Tools like OBS Studio or Game Bar cannot record the embedded game by capturing the Godot Editor process. To record the game, you must capture the entire screen or a specific section of it. This limitation is expected given the separate processes for the editor and game.
Single Window Mode and Popups/Tooltips: When the game is embedded and the editor runs in single-window mode, all popups and tooltips are displayed beneath the embedded game process.
Embedded window can be moved with OS shortcuts: When the game is embedded some Windows or Linux shortcuts came be used to move the game window. I was not able to find a way to disable those shortcuts. On Windows we are talking about WindowKey+Shit+Right/Left and on Linux WindowKey+LeftMouseButton.
Testing