1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Automatically activate camera monitoring when using CameraTexture.

This commit is contained in:
Lukas Tenbrink
2025-04-03 15:19:41 +02:00
parent 1f56d96cf2
commit e9e455823e
2 changed files with 7 additions and 1 deletions

View File

@@ -142,7 +142,12 @@ bool CameraTexture::get_camera_active() const {
}
}
CameraTexture::CameraTexture() {}
CameraTexture::CameraTexture() {
// Note: When any CameraTexture is created, we need to automatically activate monitoring
// of camera feeds. This may incur a small lag spike, so it may be preferable to
// enable it manually before creating the camera texture.
CameraServer::get_singleton()->set_monitoring_feeds(true);
}
CameraTexture::~CameraTexture() {
if (_texture.is_valid()) {

View File

@@ -42,6 +42,7 @@ void CameraServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_monitoring_feeds", "is_monitoring_feeds"), &CameraServer::set_monitoring_feeds);
ClassDB::bind_method(D_METHOD("is_monitoring_feeds"), &CameraServer::is_monitoring_feeds);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitoring_feeds"), "set_monitoring_feeds", "is_monitoring_feeds");
ADD_PROPERTY_DEFAULT("monitoring_feeds", false);
ClassDB::bind_method(D_METHOD("get_feed", "index"), &CameraServer::get_feed);
ClassDB::bind_method(D_METHOD("get_feed_count"), &CameraServer::get_feed_count);