Skip to content

Commit bdcee83

Browse files
committed
Expose Viewport::get_audio_listener_2d and Viewport::get_audio_listener_3d to scripting
Document exposed methods Apply suggestions from code review Co-authored-by: Micky <66727710+Mickeon@users.noreply.github.com> Document default behavior when no audio listeners are active
1 parent 0a4aedb commit bdcee83

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

doc/classes/Viewport.xml

+12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
Returns the first valid [World3D] for this viewport, searching the [member world_3d] property of itself and any Viewport ancestor.
3434
</description>
3535
</method>
36+
<method name="get_audio_listener_2d" qualifiers="const">
37+
<return type="AudioListener2D" />
38+
<description>
39+
Returns the currently active 2D audio listener. Returns [code]null[/code] if there are no active 2D audio listeners, in which case the active 2D camera will be treated as listener.
40+
</description>
41+
</method>
42+
<method name="get_audio_listener_3d" qualifiers="const">
43+
<return type="AudioListener3D" />
44+
<description>
45+
Returns the currently active 3D audio listener. Returns [code]null[/code] if there are no active 3D audio listeners, in which case the active 3D camera will be treated as listener.
46+
</description>
47+
</method>
3648
<method name="get_camera_2d" qualifiers="const">
3749
<return type="Camera2D" />
3850
<description>

scene/main/viewport.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -4671,6 +4671,7 @@ void Viewport::_bind_methods() {
46714671

46724672
ClassDB::bind_method(D_METHOD("set_as_audio_listener_2d", "enable"), &Viewport::set_as_audio_listener_2d);
46734673
ClassDB::bind_method(D_METHOD("is_audio_listener_2d"), &Viewport::is_audio_listener_2d);
4674+
ClassDB::bind_method(D_METHOD("get_audio_listener_2d"), &Viewport::get_audio_listener_2d);
46744675
ClassDB::bind_method(D_METHOD("get_camera_2d"), &Viewport::get_camera_2d);
46754676

46764677
#ifndef _3D_DISABLED
@@ -4681,6 +4682,7 @@ void Viewport::_bind_methods() {
46814682
ClassDB::bind_method(D_METHOD("set_use_own_world_3d", "enable"), &Viewport::set_use_own_world_3d);
46824683
ClassDB::bind_method(D_METHOD("is_using_own_world_3d"), &Viewport::is_using_own_world_3d);
46834684

4685+
ClassDB::bind_method(D_METHOD("get_audio_listener_3d"), &Viewport::get_audio_listener_3d);
46844686
ClassDB::bind_method(D_METHOD("get_camera_3d"), &Viewport::get_camera_3d);
46854687
ClassDB::bind_method(D_METHOD("set_as_audio_listener_3d", "enable"), &Viewport::set_as_audio_listener_3d);
46864688
ClassDB::bind_method(D_METHOD("is_audio_listener_3d"), &Viewport::is_audio_listener_3d);

0 commit comments

Comments
 (0)