Тёмный

How to add UI sounds in Godot 4 the smart way 

Liblast
Подписаться 1,1 тыс.
Просмотров 8 тыс.
50% 1

Get the final code here:
codeberg.org/Liblast/Liblast/...
Thanks to Timothy Qiu for telling my why didn't the Line Edit text change signals didn't work.
I had to add .unbind(1) after bind(&"UI_sound") to ignore the passed argument and make it work.
Corrected code is linked above.
---
Liblast is an open-source multiplayer FPS game built on the Godot 4 game engine. It's in early stages of developemnt, but has a dedicated team of talented individuals working on it in their spare time.
More information:
libla.st
Want to meet the people? Join the project? Get in touch!
chat.unfa.xyz/channel/liblast

Опубликовано:

 

31 окт 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 24   
@unfa00
@unfa00 Год назад
I got a message explaining why `text_changed` signal did not work: "It has a parameter. The signal emission fails because it passes one argument but the callable accepts zero. With callable binding, you can put a `.unbind(1)` after the `bind()` to ignore that extra argument." Thanks, Timothy Qiu!
@Pincelbit
@Pincelbit 2 месяца назад
Justo lo que buscaba - te ganas mi suscripción man!
@tobihudiat
@tobihudiat 11 месяцев назад
This is so cool how it works!
@DucklingsStudio
@DucklingsStudio 11 месяцев назад
Great idea! Mb using groups would be better than looking over all the nodes
@Langorithmic
@Langorithmic 4 месяца назад
i like it. that's good and really simple, and can be done through code to ensure you're not missing any
@DarkeyPro
@DarkeyPro Год назад
to find all nodes of type find_children("","Node",true,false)
@Theraot
@Theraot Год назад
Your ButtonPlus is a scene. If you instanced the scene (instead of adding a Node or changing the type of a Node, you instance a scene child… You know the chain icon that is after the plus icon in the scene panel), then it would have the AudioStreamPlayer, and the script and the signal connected. Anyway, I'm not suggesting to use scene instance, I'm just pointing how it would have worked with the first approach showed in the video.
@liblast
@liblast Год назад
Yes, though that's be even more work, wouldn't it? Or am I misunderstanding your explanation?
@sofiejensen3804
@sofiejensen3804 Год назад
10:13 the right way
@genetikx236
@genetikx236 Год назад
Great😄
@EidoEndy
@EidoEndy Год назад
Never knew about the Bus options.
@DARamosYT
@DARamosYT 7 месяцев назад
I zoned out after a bit. 10:08 to regain my bearings.
@timflatus
@timflatus 6 месяцев назад
Is it something to do with when the text_changed signal is emitted? I'm also wondering if this script could be directly attached to the ui_theme? Sound should be an attribute of the button class.
@TomasAPayer
@TomasAPayer 7 месяцев назад
How did you organize your UI scene? Each of the menu faces is it's own scene?
@Theraot
@Theraot Год назад
When something does not work, before going "we could debug this", look at the debugger to see if it is telling you there was an error.
@Spartan322
@Spartan322 Год назад
Not a bad idea, (though recursion is probably not the most optimal for performance) but I would like to point out this is not very modular, while it makes the buttons independent of their sound, there is no way for the button to modify the sound.
@liblast
@liblast Год назад
Yes, modifying the sound would require adding some custom metadata to the UI elements that'd allow the setup script to alter it's treatment. I am not sure what could be a better solution, that wouldn't require forking all Control nodes and creating a huge mess with that. The approach show here is certainly not ideal, as it's also missing any elements inside modal UI windows (that are incorrectly scaled up anyways). Maybe it can be improved somehow. I'd be glad to learn new ideas here! - unfa
@Spartan322
@Spartan322 Год назад
​@@liblast There is one way I can sort of think of off the top of my head, however its a massive hack and I have no idea on the performance implications or other possible breaks in Godot's system. But you could extend the stylebox resources with scripts, add a file export variable for the audio file, and try to detect on the first draw for the specific canvas item, and if that's true you play the sound. This might violate the styles system a little bit. Unfortunately since exports to resources are initialized after the _init function, you'd have to forward all your custom styleboxes to a singleton in the _init function in order to prep their audio streams, almost everything outside of loading and playing the audio streams has been tested by me on beta 9. (so I can't say for certain if _draw will work properly with calls to a stream player's play, note you should probably reference the stream player in the custom stylebox script and assign it with the singleton, also to note you should probably manage the sound via a setter and getter if you plan to support changing the sound by code and in game) This wouldn't be super difficult and you do get all the brilliance of the theme system doing this but again you'd be performing a massive hack to do it. Cool thing about doing this though is you do intrinsically integrate the inspector and don't have to hardcode anything. Even more is fairly efficient since resources are by reference, so its guaranteed to initialize the minimal amount you set it. One note is this would require setting up your default theme for each item you want sounds to come from. But you only have to do it once per element and you were already hardcoding it anyway.
@fkeyzuwu
@fkeyzuwu Год назад
using custom themes is what i thought this video was gonna be lol
@Danny-uo7hk
@Danny-uo7hk 2 месяца назад
The page you are trying to reach either does not exist or you are not authorized to view it.
@badunius_code
@badunius_code 9 месяцев назад
Starts at 12:55
@tavanogrim
@tavanogrim 8 месяцев назад
such an underrated comment
@hingedevoper69
@hingedevoper69 5 месяцев назад
dawg just make an autoload smh
@smugglersstudio
@smugglersstudio 5 месяцев назад
I used dumpest way. It fits my game welll) actualy its pretty minimalistic and I like It class_name ButtonSounded func _ready(): connect("mouse_entered", mouse_enter) func mouse_enter(): core.sound().hover()
Далее
choosing a game engine is easy, actually
15:08
Просмотров 337 тыс.
Ручка из шланга, лайфхак
00:11
Просмотров 16 тыс.
BETTER 2D visuals in 7 EASY TIPS
10:38
Просмотров 63 тыс.
How Games Have Worked for 30 Years to Do Less Work
23:40
I Optimised My Game Engine Up To 12000 FPS
11:58
Просмотров 587 тыс.
100+ Linux Things you Need to Know
12:23
Просмотров 765 тыс.
The Future of Game Development
8:58
Просмотров 1,2 млн
How to ACTUALLY get into Gamedev
14:01
Просмотров 699 тыс.