Skip to content

Commit bfa4372

Browse files
committed
Merge pull request godotengine#104971 from Ivorforce/camera-texture-editor-lazy
Automatically activate camera monitoring when using `CameraTexture`
2 parents 33065d8 + e9e4558 commit bfa4372

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

scene/resources/camera_texture.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ bool CameraTexture::get_camera_active() const {
142142
}
143143
}
144144

145-
CameraTexture::CameraTexture() {}
145+
CameraTexture::CameraTexture() {
146+
// Note: When any CameraTexture is created, we need to automatically activate monitoring
147+
// of camera feeds. This may incur a small lag spike, so it may be preferable to
148+
// enable it manually before creating the camera texture.
149+
CameraServer::get_singleton()->set_monitoring_feeds(true);
150+
}
146151

147152
CameraTexture::~CameraTexture() {
148153
if (_texture.is_valid()) {

servers/camera_server.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void CameraServer::_bind_methods() {
4242
ClassDB::bind_method(D_METHOD("set_monitoring_feeds", "is_monitoring_feeds"), &CameraServer::set_monitoring_feeds);
4343
ClassDB::bind_method(D_METHOD("is_monitoring_feeds"), &CameraServer::is_monitoring_feeds);
4444
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitoring_feeds"), "set_monitoring_feeds", "is_monitoring_feeds");
45+
ADD_PROPERTY_DEFAULT("monitoring_feeds", false);
4546

4647
ClassDB::bind_method(D_METHOD("get_feed", "index"), &CameraServer::get_feed);
4748
ClassDB::bind_method(D_METHOD("get_feed_count"), &CameraServer::get_feed_count);

0 commit comments

Comments
 (0)