Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix issues when disabling the Game view feature

Michael Alexsandera72a0d90e08f
diff --git a/editor/run/game_view_plugin.cpp b/editor/run/game_view_plugin.cpp
index 3c528c02bc8..1cf98ef695e 100644
--- a/editor/run/game_view_plugin.cpp
+++ b/editor/run/game_view_plugin.cpp
@@ -68,10 +68,6 @@
#include "servers/display/display_server.h"
void GameViewDebugger::_session_started(Ref<EditorDebuggerSession> p_session) {
- if (!is_feature_enabled) {
- return;
- }
-
bool is_native = EditorRunBar::get_singleton()->is_running_natively();
Dictionary settings;
@@ -175,10 +171,12 @@ void GameViewDebugger::_session_started(Ref<EditorDebuggerSession> p_session) {
}
void GameViewDebugger::_session_stopped() {
- if (!is_feature_enabled) {
+ if (!is_feature_enabled && !was_feature_disabled_mid_play) {
return;
}
+ was_feature_disabled_mid_play = false;
+
emit_signal(SNAME("session_stopped"));
}
@@ -396,6 +394,7 @@ void GameViewDebugger::setup_session(int p_session_id) {
void GameViewDebugger::_feature_profile_changed() {
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
is_feature_enabled = profile.is_null() || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME);
+ was_feature_disabled_mid_play = !is_feature_enabled && EditorRunBar::get_singleton()->is_playing();
}
void GameViewDebugger::_bind_methods() {
@@ -643,7 +642,7 @@ void GameView::_play_pressed() {
}
void GameView::_stop_pressed() {
- if (!is_feature_enabled) {
+ if (!is_feature_enabled && !was_feature_disabled_mid_play) {
return;
}
@@ -665,6 +664,8 @@ void GameView::_stop_pressed() {
screen_index_before_start = -1;
+ was_feature_disabled_mid_play = false;
+
if (InspectorDock::get_inspector_singleton()->is_connected(SNAME("edited_object_changed"), callable_mp(this, &GameView::_inspector_object_changed))) {
InspectorDock::get_inspector_singleton()->disconnect(SNAME("edited_object_changed"), callable_mp(this, &GameView::_inspector_object_changed));
}
@@ -719,7 +720,7 @@ void GameView::_inspector_object_changed() {
void GameView::_update_debugger_buttons() {
bool empty = active_sessions == 0;
- suspend_button->set_disabled(empty);
+ suspend_button->set_disabled(empty || !is_feature_enabled);
camera_override_button->set_disabled(empty);
speed_state_button->set_disabled(empty);
game_size_label->set_visible(!empty);
@@ -1502,8 +1503,30 @@ void GameView::_debugger_breaked(bool p_breaked, bool p_can_debug) {
void GameView::_feature_profile_changed() {
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
bool is_profile_null = profile.is_null();
-
is_feature_enabled = is_profile_null || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME);
+ was_feature_disabled_mid_play = !is_feature_enabled && EditorRunBar::get_singleton()->is_playing();
+
+ if (!is_feature_enabled) {
+ if (!node_type_button[RuntimeNodeSelect::NODE_TYPE_NONE]->is_pressed()) {
+ node_type_button[RuntimeNodeSelect::NODE_TYPE_NONE]->set_pressed(true);
+ _node_type_pressed(RuntimeNodeSelect::NODE_TYPE_NONE);
+ }
+
+ suspend_button->set_pressed(false);
+ camera_override_button->set_pressed(false);
+
+ _reset_time_scales();
+
+ if (debug_mute_audio) {
+ _debug_mute_audio_button_pressed();
+ }
+
+ // If the game is currently being played and embedded, stop the game.
+ // Otherwise it would just get stuck in the now inaccessible Game view.
+ _window_close_request();
+ }
+
+ suspend_button->set_disabled(active_sessions == 0 || !is_feature_enabled);
bool is_3d_enabled = is_profile_null || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D);
if (!is_3d_enabled && node_type_button[RuntimeNodeSelect::NODE_TYPE_3D]->is_pressed()) {
diff --git a/editor/run/game_view_plugin.h b/editor/run/game_view_plugin.h
index 25f1c392470..b40fe0bed7b 100644
--- a/editor/run/game_view_plugin.h
+++ b/editor/run/game_view_plugin.h
@@ -53,6 +53,7 @@ private:
Vector<Ref<EditorDebuggerSession>> sessions;
bool is_feature_enabled = true;
+ bool was_feature_disabled_mid_play = false;
int node_type = RuntimeNodeSelect::NODE_TYPE_NONE;
bool selection_visible = true;
int ci_tool = CanvasItemManipulator::TOOL_SELECT;
@@ -183,6 +184,7 @@ class GameView : public VBoxContainer {
EditorDock *game_dock = nullptr;
bool is_feature_enabled = true;
+ bool was_feature_disabled_mid_play = false;
int active_sessions = 0;
int screen_index_before_start = -1;
ScriptEditorDebugger *embedded_script_debugger = nullptr;
diff --git a/scene/debugger/runtime_node_select.cpp b/scene/debugger/runtime_node_select.cpp
index c0717e2a3b1..bd5d1cd91d3 100644
--- a/scene/debugger/runtime_node_select.cpp
+++ b/scene/debugger/runtime_node_select.cpp
@@ -599,19 +599,21 @@ void RuntimeNodeSelect::_scene_double_clicked(const String &p_path) {
void RuntimeNodeSelect::_process_frame() {
#ifndef _3D_DISABLED
- // Calculate the process time manually, as the time scale can be frozen.
- const double process_time = (1.0 / Engine::get_singleton()->get_frames_per_second());
+ if (SceneTree::get_singleton()->get_root()->is_camera_3d_override_enabled()) {
+ // Calculate the process time manually, as the time scale can be frozen.
+ const double process_time = (1.0 / Engine::get_singleton()->get_frames_per_second());
- if (view_3d_controller->is_freelook_enabled()) {
- bool was_input_disabled = Input::get_singleton()->is_input_disabled();
- Input::get_singleton()->set_disable_input(false);
+ if (view_3d_controller->is_freelook_enabled()) {
+ bool was_input_disabled = Input::get_singleton()->is_input_disabled();
+ Input::get_singleton()->set_disable_input(false);
- view_3d_controller->update_freelook(process_time);
+ view_3d_controller->update_freelook(process_time);
- Input::get_singleton()->set_disable_input(was_input_disabled);
- }
+ Input::get_singleton()->set_disable_input(was_input_disabled);
+ }
- view_3d_controller->update_camera(process_time);
+ view_3d_controller->update_camera(process_time);
+ }
#endif // _3D_DISABLED
if (selection_update_queued || !SceneTree::get_singleton()->is_suspended()) {