godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.06k stars 65 forks source link

Create an `AudioStreamPlayer` when an `AudioStream` is dropped into the scene #9699

Closed passivestar closed 1 week ago

passivestar commented 3 weeks ago

Describe the project you are working on

Quick game prototypes

Describe the problem or limitation you are having in your project

Adding sounds to the game could be a bit quicker

In Unity dropping a sound file into the hierarchy automatically creates a player for it. This QOL feature is convenient for quick game prototypes where you're not using any kind of a centralized audio manager singleton to play streams through, or if you're purposefully avoiding having such a singleton if you're trying to make game entities more self-contained

Describe the feature / enhancement and how it helps to overcome the problem or limitation

When you drop an AudioStream resource from the FileSystem dock onto a node in the Scene dock or into the viewport it would automatically create an appropriate AudioStreamPlayer node and set its stream property to that resource

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The type of the node would depend on where you're dropping the stream:

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not in a few

Is there a reason why this should be core and not an add-on in the asset library?

A small QOL editor feature

mieldepoche commented 3 weeks ago

afaik dropping a resource on a node in the tree usually means "set a property": for example dropping a texture on a Sprite2D, or an AudioStream on an AudioStreamPlayer (or any node that has an AudioStream property).

Dropping an `AudioStream` on a node that has an `AudioStream` property https://github.com/godotengine/godot-proposals/assets/71937306/3d74f3ce-e289-4d39-b92c-1c42e8fa2ff9
passivestar commented 3 weeks ago

@mieldepoche it could keep the old behavior if the node has a stream property and add a new node if it doesn't

KoBeWi commented 3 weeks ago

We could enable dropping in between nodes when dragging resource. Right now you can drop only on top of node.

https://github.com/godotengine/godot-proposals/assets/2223172/0b414627-bd3f-4692-abe7-9139c02b20ea