-
-
Notifications
You must be signed in to change notification settings - Fork 22.1k
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
Android Editor: Add immersive mode option #94285
Conversation
This allows using the Android Godot Editor in immersive mode, making the most of available screen space. Pre-commit hooks were skipped due to the following errors, that, to my knowledge, are outside of the scope of this PR: ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_dependencies" description. ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_dependencies_maven_repos" description. ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_libraries" description. ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_manifest_activity_element_contents" description. ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_manifest_application_element_contents" description. ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_manifest_element_contents" description.
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.
Have you tested how immersive mode behaves on tablet when the editor window is opened side-by-side with the running project window?
* For now, once you go immersive, you can't go back. | ||
* Call only from UI thread. | ||
*/ | ||
fun goImmersive() { |
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.
Let's rename the method to enableImmersive()
and give it internal
visibility.
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.
This cannot be both internal
and also accessed from GodotEditor, so I'll do the latter.
if (useImmersive) | ||
return |
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.
Missing brackets
} else { | ||
val shouldGoImmersive = java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/editor/android/immersive_mode")) | ||
|
||
runOnUiThread { | ||
if (shouldGoImmersive) | ||
goImmersive() | ||
} |
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.
Let's move this logic to GodotEditor
and have that class invoke Godot::enableImmersive()
as needed.
There is one additional thing we need to consider; should the running project window also open in immersive mode if the editor is immersive?
- If yes, then the logic can be copied as is
GodotEditor
- If no, then you need to provide a method that
GodotGame.kt
can override to declare whether it should be immersive. SeeGodotEditor#enableLongPressGestures()
andGodotGame#enableLongPressGestures()
for example.
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've added a separate option for the game. This option uses the --use_immersive
functionality that already existed.
… immersive mode option
…ad, kind of feels threading-risky
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.
@20kdc Sorry for the delay - I've tested the changes and they look pretty good! This will be a good feature to include for the Godot 4.4 release!
A couple of feedback on the PR:
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/android/editor_immersive_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/android/game_immersive_mode", false, "", PROPERTY_USAGE_DEFAULT)
- Instead of having two editor settings, let's use a single
interface/editor/android/immersive_mode
to control immersive mode for both the editor and the play/game window- Also let's remove the
ANDROID_ENABLED
guards around the setting. The fact it's under theandroid
section should be sufficient to point out the setting is only active on Android.
- Also let's remove the
This option uses the --use_immersive functionality that already existed.
I like the approach of re-using the --use_immersive
functionality and I think we can update the PR logic to only use that approach for both the editor and the play/game window. In order to do so
- The logic in
editor_run
should be moved toGodotEditor#onNewGodotInstanceRequested(...)
. - As done in
editor_run
, the logic should check ifimmersive_mode
is enabled, and if so add the immersive flag in theargs
parameter if it doesn't contain it already.- With this approach, the PR should only require changes in
editor_settings
to introduce the setting, and inGodotEditor
to update the launch parameters as needed - This also means that the project settings will not launch in immersive mode when launch from the library, but I think that's fine as the primary use case is to have the editor window in immersive mode.
- With this approach, the PR should only require changes in
Found out from testing that saving and reading the editor setting at restart time does not seem to work for some reason (the update editor setting value is not being picked up). |
Ah, thank you. |
This allows using the Android Godot Editor in immersive mode, making the most of available screen space.
When this setting is enabled, Godot will change into immersive mode mid-startup, as the editor settings are not available until then. (A marker file was considered, but this seemed neater, all things considered. If it works well enough, it also implies that dynamically switching to immersive mode might be a future feature.)
Pre-commit hooks were skipped due to errors in the class reference that, to my knowledge, are outside of the scope of this PR. See the commit message for details. No code formatting errors were detected by the stages that did succeed.