You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Check if OpenXR is enabled with feature tags of export preset
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include "openxr_editor_plugin.h"
|
#include "openxr_editor_plugin.h"
|
||||||
|
|
||||||
#include "../action_map/openxr_action_map.h"
|
#include "../action_map/openxr_action_map.h"
|
||||||
|
#include "../openxr_api.h"
|
||||||
|
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/gui/editor_bottom_panel.h"
|
#include "editor/gui/editor_bottom_panel.h"
|
||||||
@@ -47,9 +48,12 @@ bool OpenXRExportPlugin::supports_platform(const Ref<EditorExportPlatform> &p_ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OpenXRExportPlugin::is_openxr_mode() const {
|
bool OpenXRExportPlugin::is_openxr_mode() const {
|
||||||
|
// Check if OpenXR is enabled using `EditorExportPlatform::get_project_settings()` because that'll
|
||||||
|
// take into account the feature tags on the specific export preset that is being exported.
|
||||||
|
bool openxr_enabled = (bool)get_export_platform()->get_project_setting(get_export_preset(), "xr/openxr/enabled");
|
||||||
int xr_mode_index = get_option("xr_features/xr_mode");
|
int xr_mode_index = get_option("xr_features/xr_mode");
|
||||||
|
|
||||||
return xr_mode_index == XR_MODE_OPENXR;
|
return openxr_enabled && xr_mode_index == XR_MODE_OPENXR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OpenXRExportPlugin::_get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const {
|
String OpenXRExportPlugin::_get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const {
|
||||||
@@ -150,7 +154,7 @@ String OpenXRExportPlugin::get_android_manifest_activity_element_contents(const
|
|||||||
// OpenXREditorPlugin
|
// OpenXREditorPlugin
|
||||||
|
|
||||||
void OpenXREditorPlugin::edit(Object *p_node) {
|
void OpenXREditorPlugin::edit(Object *p_node) {
|
||||||
if (Object::cast_to<OpenXRActionMap>(p_node)) {
|
if (action_map_editor && Object::cast_to<OpenXRActionMap>(p_node)) {
|
||||||
String path = Object::cast_to<OpenXRActionMap>(p_node)->get_path();
|
String path = Object::cast_to<OpenXRActionMap>(p_node)->get_path();
|
||||||
if (path.is_resource_file()) {
|
if (path.is_resource_file()) {
|
||||||
action_map_editor->open_action_map(path);
|
action_map_editor->open_action_map(path);
|
||||||
@@ -159,13 +163,18 @@ void OpenXREditorPlugin::edit(Object *p_node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OpenXREditorPlugin::handles(Object *p_node) const {
|
bool OpenXREditorPlugin::handles(Object *p_node) const {
|
||||||
|
if (action_map_editor) {
|
||||||
return (Object::cast_to<OpenXRActionMap>(p_node) != nullptr);
|
return (Object::cast_to<OpenXRActionMap>(p_node) != nullptr);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void OpenXREditorPlugin::make_visible(bool p_visible) {
|
void OpenXREditorPlugin::make_visible(bool p_visible) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenXREditorPlugin::OpenXREditorPlugin() {
|
OpenXREditorPlugin::OpenXREditorPlugin() {
|
||||||
|
// Only add our OpenXR action map editor if OpenXR is enabled for the whole project.
|
||||||
|
if (OpenXRAPI::openxr_is_enabled(false)) {
|
||||||
action_map_editor = memnew(OpenXRActionMapEditor);
|
action_map_editor = memnew(OpenXRActionMapEditor);
|
||||||
EditorNode::get_bottom_panel()->add_item(TTRC("OpenXR Action Map"), action_map_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_openxr_action_map_bottom_panel", TTRC("Toggle OpenXR Action Map Bottom Panel")));
|
EditorNode::get_bottom_panel()->add_item(TTRC("OpenXR Action Map"), action_map_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_openxr_action_map_bottom_panel", TTRC("Toggle OpenXR Action Map Bottom Panel")));
|
||||||
|
|
||||||
@@ -177,6 +186,7 @@ OpenXREditorPlugin::OpenXREditorPlugin() {
|
|||||||
add_control_to_container(CONTAINER_TOOLBAR, select_runtime);
|
add_control_to_container(CONTAINER_TOOLBAR, select_runtime);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OpenXREditorPlugin::_notification(int p_what) {
|
void OpenXREditorPlugin::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
|
|||||||
@@ -109,18 +109,16 @@ static Ref<OpenXRInterface> openxr_interface;
|
|||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
static void _editor_init() {
|
static void _editor_init() {
|
||||||
if (OpenXRAPI::openxr_is_enabled(false)) {
|
if (OpenXRAPI::openxr_is_enabled(false)) {
|
||||||
// Only add our OpenXR action map editor if OpenXR is enabled for our project
|
|
||||||
|
|
||||||
if (openxr_interaction_profile_metadata == nullptr) {
|
if (openxr_interaction_profile_metadata == nullptr) {
|
||||||
// If we didn't initialize our actionmap metadata at startup, we initialize it now.
|
// If we didn't initialize our actionmap metadata at startup, we initialize it now.
|
||||||
openxr_interaction_profile_metadata = memnew(OpenXRInteractionProfileMetadata);
|
openxr_interaction_profile_metadata = memnew(OpenXRInteractionProfileMetadata);
|
||||||
ERR_FAIL_NULL(openxr_interaction_profile_metadata);
|
ERR_FAIL_NULL(openxr_interaction_profile_metadata);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OpenXREditorPlugin *openxr_plugin = memnew(OpenXREditorPlugin());
|
OpenXREditorPlugin *openxr_plugin = memnew(OpenXREditorPlugin());
|
||||||
EditorNode::get_singleton()->add_editor_plugin(openxr_plugin);
|
EditorNode::get_singleton()->add_editor_plugin(openxr_plugin);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initialize_openxr_module(ModuleInitializationLevel p_level) {
|
void initialize_openxr_module(ModuleInitializationLevel p_level) {
|
||||||
|
|||||||
Reference in New Issue
Block a user