Skip to content
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

Implement instant splash screen for Meta devices #255

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions plugin/src/main/cpp/export/meta_export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() {
PROPERTY_USAGE_DEFAULT,
BOUNDARY_ENABLED_VALUE,
false);
_instant_splash_screen_option = _generate_export_option(
"meta_xr_features/instant_splash_screen",
"",
Variant::Type::BOOL,
PROPERTY_HINT_NONE,
"",
PROPERTY_USAGE_DEFAULT,
false,
false);
_support_quest_1_option = _generate_export_option(
"meta_xr_features/quest_1_support",
"",
Expand Down Expand Up @@ -229,6 +238,7 @@ TypedArray<Dictionary> MetaEditorExportPlugin::_get_export_options(const Ref<Edi
export_options.append(_use_overlay_keyboard_option);
export_options.append(_use_experimental_features_option);
export_options.append(_boundary_mode_option);
export_options.append(_instant_splash_screen_option);
export_options.append(_support_quest_1_option);
export_options.append(_support_quest_2_option);
export_options.append(_support_quest_3_option);
Expand Down Expand Up @@ -340,6 +350,10 @@ String MetaEditorExportPlugin::_get_export_option_warning(const Ref<EditorExport
if (!openxr_enabled && _get_int_option(option, BOUNDARY_ENABLED_VALUE) > BOUNDARY_ENABLED_VALUE) {
return "Boundary mode changes require \"XR Mode\" to be \"OpenXR\".\n";
}
} else if (option == "meta_xr_features/instant_splash_screen") {
if (!openxr_enabled && _get_bool_option(option)) {
return "\"Instant splash screen\" is only valid when \"XR Mode\" is \"OpenXR\".\n";
}
}

return OpenXREditorExportPlugin::_get_export_option_warning(platform, option);
Expand Down Expand Up @@ -458,6 +472,21 @@ String MetaEditorExportPlugin::_get_android_manifest_element_contents(const Ref<
return contents;
}

void MetaEditorExportPlugin::_export_begin(const PackedStringArray &p_features, bool p_is_debug, const String &p_path, uint32_t p_flags) {
bool instant_splash_screen = _get_bool_option("meta_xr_features/instant_splash_screen");
if (!instant_splash_screen) {
return;
}

String boot_splash_path = ProjectSettings::get_singleton()->get_setting_with_override("application/boot_splash/image");
if (!FileAccess::file_exists(boot_splash_path)) {
return;
}

PackedByteArray boot_splash_file = FileAccess::get_file_as_bytes(boot_splash_path);
add_file("res://vr_splash.png", boot_splash_file, true);
}

String MetaEditorExportPlugin::_get_android_manifest_application_element_contents(const Ref<EditorExportPlatform> &platform, bool debug) const {
String contents;
if (!_supports_platform(platform) || !_is_vendor_plugin_enabled()) {
Expand All @@ -475,6 +504,11 @@ String MetaEditorExportPlugin::_get_android_manifest_application_element_content
contents += " <meta-data tools:node=\"replace\" android:name=\"com.oculus.handtracking.version\" android:value=\"V2.0\" />\n";
}

bool instant_splash_screen = _get_bool_option("meta_xr_features/instant_splash_screen");
if (instant_splash_screen) {
contents += " <meta-data android:name=\"com.oculus.ossplash\" android:value=\"true\"/>\n";
}

if ((int)ProjectSettings::get_singleton()->get_setting_with_override("xr/openxr/environment_blend_mode") != XRInterface::XR_ENV_BLEND_MODE_OPAQUE) {
// Show the splash screen in passthrough, if the user launches it from passthrough.
contents += " <meta-data android:name=\"com.oculus.ossplash.background\" android:value=\"passthrough-contextual\" />\n";
Expand Down
3 changes: 3 additions & 0 deletions plugin/src/main/cpp/include/export/meta_export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class MetaEditorExportPlugin : public OpenXREditorExportPlugin {
String _get_android_manifest_application_element_contents(const Ref<EditorExportPlatform> &platform, bool debug) const override;
String _get_android_manifest_element_contents(const Ref<EditorExportPlatform> &platform, bool debug) const override;

virtual void _export_begin(const PackedStringArray &p_features, bool p_is_debug, const String &p_path, uint32_t p_flags) override;

protected:
static void _bind_methods();

Expand All @@ -104,6 +106,7 @@ class MetaEditorExportPlugin : public OpenXREditorExportPlugin {
Dictionary _use_overlay_keyboard_option;
Dictionary _use_experimental_features_option;
Dictionary _boundary_mode_option;
Dictionary _instant_splash_screen_option;
Dictionary _support_quest_1_option;
Dictionary _support_quest_2_option;
Dictionary _support_quest_3_option;
Expand Down
Loading