AudioStreamPlayer2D does not work when it is inside a CanvasLayer
Godot version: 3.x custom built from aeb1c67b5b55c769256a8ffc2f9d9095d6fc74da
OS/device including version: Windows 10
Issue description:
Whenever an AudioStreamPlayer2D
is inside a CanvasLayer
, it will be silent (it will not work). After initial debugging, I found that this is due to:
-
CanvasLayers
have their ownworld_2ds
-
CanvasLayers
world_2ds
somehow don't get the defaultViewport
added to it's internal list. - When
AudioStreamPlayer2D
checks whether it is inside aworld_2d
that has a viewport attached that is anaudio_listener_2d
, it doesn't find any because theCanvasLayer
'sworld_2d
's viewport list is empty.
Relavant lines in AudioStreamPlayer2D
:
https://github.com/godotengine/godot/blob/aeb1c67b5b55c769256a8ffc2f9d9095d6fc74da/scene/2d/audio_stream_player_2d.cpp#L182-L186
Line 182 results in an empty list of viewports when inside a CanvasLayer
Steps to reproduce: Put an AudioStreamPlayer2D inside a CanvasLayer and call play() on it. It will be silent.
Minimal reproduction project: audioCanvasLayer.zip