-
-
Notifications
You must be signed in to change notification settings - Fork 22.4k
Fix transparency background issue on Android #106709
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
base: master
Are you sure you want to change the base?
Conversation
bool EditorExportPlatformAndroid::_should_be_transparent(const Ref<EditorExportPreset> &p_preset) const { | ||
return (bool)get_project_setting(p_preset, "display/window/per_pixel_transparency/allowed") && | ||
(bool)get_project_setting(p_preset, "display/window/size/transparent") && | ||
(bool)get_project_setting(p_preset, "rendering/viewport/transparent_background"); |
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.
rendering/viewport/transparent_background
check is probably excessive, on desktop platforms setting display/window/size/transparent
(or transparent
flag for the Window
) will automatically set viewport background to transparent regardless of this setting.
} else if (line.contains("\"android:windowIsTranslucent\">")) { | ||
lines.set(i, vformat(" <item name=\"android:windowIsTranslucent\">%s</item>", bool_to_string(should_be_transparent))); | ||
modified = true; | ||
} else if (line.contains("\"android:windowBackground\"")) { | ||
if (should_be_transparent) { | ||
lines.set(i, " <item name=\"android:windowBackground\">@android:color/transparent</item>"); | ||
} else { | ||
lines.set(i, " <!--<item name=\"android:windowBackground\">@android:color/transparent</item>-->"); | ||
} | ||
modified = true; | ||
} |
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.
@m4gr3d Since we're now relying on multiple theme attributes, the current setup is becoming error-prone.
For example, if a user manually edits themes.xml
and removes the android:windowIsTranslucent
attribute, the check if (line.contains("\"android:windowIsTranslucent\">"))
would fail, making this feature silently stop working.
While we could add individual found_*
booleans for each attribute, that quickly gets messy.
I opened PR #106724, which re-generates the GodotAppMainTheme
during export. This prevents manual changes from causing issues and adds a new export option for injecting custom theme attributes in a cleaner way.
Switching to draft until #106724 is merged. |
4b60b04
to
335cc7e
Compare
335cc7e
to
7a15ea7
Compare
Updates the logic to detect when transparency is required on Android using
display/window/per_pixel_transparency/allowed
,display/window/size/transparent
, andrendering/viewport/transparent_background
, which updates the render view configuration and the app's theme.The requirement to update the app's theme means the feature is only available to
gradle
build exports.Fixes #106703
Before
Screen_Recording_20250522_001406_GLTF.Viewer.mp4
After
Screen_Recording_20250522_001458_GLTF.Viewer.mp4