Unity AUDIO MANAGER Tutorial
In this video we will learn Audio Manager in unity.
We gonna write Audio manager code in c#.
We'll learn how to use SFX and music in Unity.
Audio Source Component in unity.
Enjoy the video ☕
🖐 Hi Game developer
Welcome to Rehope Games I'm Murat
I share unity tutorial videos on my channel. if you want to make a game with unity (especially 2d platformer game), the videos here will definitely interest you.
#unitytutorials, #unity2d, #unity2dplatformer
Пікірлер: 157
Hands down the best audio tutorial on the internet, i didn't only learn how to add and manage audio in my game but also learnt new development practices, THANK YOU!
@RehopeGames
8 ай бұрын
I'm glad hear that , Thanks 🙏
@hocineache7033
8 ай бұрын
@@RehopeGames please in the future make a video on how to add and unlock skins if possible, Thank you
such a simple tutorial, really well explained and straight to the point, thanks so much!
You would not believe how much you helped me!! Thank you for making this video!!!
@RehopeGames
6 ай бұрын
Thanks for the feedback, I'm glad it help you 😊
Thank you very much. This is the video is was searching for sooooooo long tim. thx!!
@RehopeGames
Жыл бұрын
Glad I could help! thank you so much for your feedback 😊
감사합니다 unity 공부중인데 덕분에 배경음악하고 효과음 넣었어요 !! Thank you!!
@RehopeGames
7 ай бұрын
귀하의 의견에 감사드립니다. 영상이 도움이 되셨다니 기쁘네요. 🙏😊
Very elegant solution. Thank you very much for sharing!
Incredible tutorial! very direct and informative. Tysm
@RehopeGames
Жыл бұрын
Glad it was helpful! Thanks for nice feedback 😊🙏
nyc Clear, easy and is working perfect.
@RehopeGames
Жыл бұрын
Thank you for your nice feedback 🙏 I wish you success in your project 😊
Thank you for your helping
Murat ağzına sağlık izlediğim en iyi audio manager tutorial'ydı
@RehopeGames
9 ай бұрын
Teşekkürler kardeşim yüreğine sağlık 😊
Muchisimas gracias amigo!!🎉😊
@RehopeGames
Жыл бұрын
gracias por tu lindo comentario 😊
Aksanından kesin bu türktür dedim içimden. Sonra kanalın açıklama kısmından adının Murat olduğunu gördüm 😊 konuşman gayet başarılı ve çok güzel videoların var. Başarılar dilerim.
@RehopeGames
Жыл бұрын
😊 Merhaba Semih hocam, Globale iş yapmak için kanalı ingilizce açmayı tercih ettim , bu vesileyle de ingilizcemi geliştirmeye devam ediyorum. İyi dileğiniz için çok teşekkür ederim , size de kanalınızda başarılar dilerim 🙏
@semihaksoy8182
Жыл бұрын
@@RehopeGames Ben video çekmiyorum artık. Kendi oyunum üstünde çalışıyorum 😊C#’a başlayalı bir buçuk ay oldu. Araştırma yaparken karşıma çıktın. Videoların çok güzel. Ben de seninkiler gibi videolar izleyip uygulayarak oyunumu ilerletiyorum.
Amazing, thank you for this tutorial
@RehopeGames
Жыл бұрын
Glad you liked it! Thanks for your nice feedback 🙏
Very helpful thank you! I enjoyed the pace, but I agree this definitely does not feel accessible to beginners.
@RehopeGames
Жыл бұрын
Hmm 🤔 Thanks for your feedback 😊🙏
First - really good video helped me really out yet 😊 great work! But my question ist how can I do the left - + in the yellow line....really better then on my VS code but don't know how to use or make it, it's without an plugin?
nice tutorial, thank you ❤❤❤
@RehopeGames
Жыл бұрын
🙏
When I tried testing the music it gave a object null reference for this line (musicSource.clip = p.clip;) is there a way to fix this?
@ginger6300
6 ай бұрын
im having the same problem might need a fix
@Sploooply
6 ай бұрын
THIS IS UNEXCEPTABLE
@Kejody53
3 ай бұрын
thats either a problem with getting the music source from audio manager or a problem with the sound clip. i think its a problem with the music source since the sound clip has a way of checking if its null or not. check if you dragged the "MusicSource" game object into the "Music Source" in the Audio Manager script in the editor
amazing, thank you!
@RehopeGames
Жыл бұрын
Thanks Tiki 🙏
Best
Thank you Murat :)
@RehopeGames
Жыл бұрын
Rica ederim, biz teşekkür ederiz 😊
Very helpful thank you so much~~
@RehopeGames
8 ай бұрын
I'm glad hear that, Thanks for your nice feedback 🙏
Murat kardeşim çok iyi video olmuş, adamsın.
@RehopeGames
Жыл бұрын
Çok teşekkür ederim güzel bildirimin için Yiğit kardeşim 🙏
nice tutorial
@RehopeGames
Жыл бұрын
Thank you so much 😊
Bravo !!!!
@RehopeGames
Жыл бұрын
Thank you so much 😊
you should provide the code in the description it would be very convenient !
@RehopeGames
Жыл бұрын
You are right 👍
How does this work with spatial sound and 3D audio? If the audio source is one 1 of them, can you have multiple sounds form different directions still?
kanka sunlari git falan yukseydin keske daha kolay calardik , eline saglik yine de qwdqdawd
Thank you very much.
@RehopeGames
Жыл бұрын
Thank you Tigran 😊
@tigranavagyan5922
Жыл бұрын
@@RehopeGames don't get me wrong, but could you change "tigran" to "Tigran". That's my name)
@RehopeGames
Жыл бұрын
@@tigranavagyan5922 Sorry 🙏
@tigranavagyan5922
Жыл бұрын
@@RehopeGames nah, everything is fine. Thanks.
thanks
Thank you so much for helpful video!! I have one question near 5:20 part, if i have a next stage and if i want to put the music back on , what code should i add?
@RehopeGames
7 ай бұрын
Hello thanks for your feedback 😊 If you wanna save Audio Settings you can watch this kzread.info/dash/bejne/eWF-t9JxcbCrqJM.html If you want the music to continue uninterrupted between scenes, you can watch this video. kzread.info/dash/bejne/qqerp9KHoNjJirQ.html
@gustavnrregaard2962
2 ай бұрын
@@RehopeGames Can you make so if i mute the sound, and we got in the next stage, it would still be muted ( if you use save playerprefs.?)
Just a little bit slower would help massively, but still a good video. (Yes I know I can change the speed for those of you rolling your eyes 😂✌) Thanks👍
@RehopeGames
5 ай бұрын
Thank you for your suggestion 😊
@L1ghtOn3
5 ай бұрын
@@RehopeGames No problem, you were much better in your 2nd video, you are doing gd work my friend, keep it up and much appreciated. 🤝✌
I will like this vi de o
Can I play multiple sounds at once with this sound manager? I am working on a 2d game and ask myself what happend if two gameobjects want to call a sound.
Hi this is amazing tutorial!!! Clear, easy and is working perfect. I have question how to implemenet random multiple background music with this? I try implement Random but then i get error with array because they use unity System. Thank you
@RehopeGames
Жыл бұрын
Hi! I'm glad you found the tutorial helpful. To implement random multiple background music using only one C# script, you would use Unity's audio system and create an array of audio clips. Here's a simple example to help you get started: 1.First, make sure you have your selected music tracks imported into your Unity project. 2. Create an empty GameObject in your scene and name it something like 'BackgroundMusicManager.' 3. In the Inspector, click on 'Add Component' and create a new C# script called 'BackgroundMusicManager.' 4. Open the BackgroundMusicManager script and add the following code: using System.Collections; using UnityEngine; public class BackgroundMusicManager : MonoBehaviour { public AudioClip[] backgroundMusicArray; private AudioSource audioSource; private void Start() { audioSource = gameObject.AddComponent(); audioSource.loop = false; if(backgroundMusicArray.Length != 0) { StartCoroutine(PlayRandomMusic()); } } IEnumerator PlayRandomMusic() { while (true) { var randomClip = backgroundMusicArray[Random.Range(0, backgroundMusicArray.Length)]; audioSource.clip = randomClip; audioSource.Play(); yield return new WaitForSeconds(audioSource.clip.length); } } } 5. Save the script and go back to the Unity editor. 6. In the 'BackgroundMusicManager' GameObject, assign your music clips to the public 'backgroundMusicArray' field. You can add as many as you want. Now when you run your game, the script will select and play random music tracks from the array in a continuous loop. If you encounter any errors, please double-check your code and ensure it matches the example provided. I hope this helps! Let me know if you have any questions, and happy coding!
@marekpuchon4878
Жыл бұрын
@@RehopeGames wau thank you
@RehopeGames
Жыл бұрын
Thank you so much 🙏
@marekpuchon4878
Жыл бұрын
@@RehopeGames Hi it works but only as selfstanding script. What i meant was implement random background music into script from this tutorial. I cant use random and array in one script and that is what make this problem for me. I cant found way around. And when i have two script for sound it make errors later in game.
thank you
@RehopeGames
Жыл бұрын
thank yo too 😊
Hi Sir thanks for your tutorial, but May I know 1.how to carry the save music setting from scene to other scene ,i have no idea after watching the video tutorial😅? 2. how the music button and sfx button become grey after clicked and vice versa?
Do you have the tutorial of how you start creating that audio? like on how you create the ui buttons of music and sfx?
@RehopeGames
Жыл бұрын
I created the UI button by using Adobe Illustrator . And I used Licensed music and sfx sound from Artlist. artlist.io/Murat-2754165
Hi, It works so well but i want to put different music on my main menu scene, so i copy the Audio Manager and paste in main menu scene, and change the audio clip. (As you mentioned in other video’s comment).Main menu music is playing well with the music i wanted to put, but when it goes to next scene (when player clicked game start button and when game started) it still playing the same song from the main menu and some of the sfx sound is not working . I checked all your other comments from other video and tried to put the code that you mention on my AudioManager script but it doesn’t work 😭 I like how you create the code in this video but should I use different code to make it work? By the way, your video is awesome!!
@RehopeGames
7 ай бұрын
Hi , You can make it as Singleton. Research singleton pattern bro. Thanks for the feedback 🙏
Nice Tutorial, thank you. could please you give me some hints to save the setting permanently ?
@RehopeGames
Жыл бұрын
thank you so much 🙏 this video will be helpful kzread.info/dash/bejne/eWF-t9JxcbCrqJM.html
@gamehub24275
Жыл бұрын
@@RehopeGames Thank you i will check it :)
Hello! Please help! error CS1061: 'Sound' does not contain a definition for 'clip' and no accessible extension method 'clip' accepting a first argument of type 'Sound' could be found (are you missing a using directive or an assembly reference?)
@thobraa
4 ай бұрын
Try removing : monobehaviour from your sound class (script). So it says "public class Sound" instead of "public class Sound : Monobehaviour" Hope this helps. I had the same error.
what Audioclip should I put in the SFX Source in the Hierachy? I've followed you but its not working
@RehopeGames
Жыл бұрын
Sorry for getting back to you late , I hope you solved this problem.
Bro the sound class didnt worked in my unity it is saying that namespace sound couldnt be found how can I fix that
great video i love it from the very beginning buh one issues the script on the slider and the mute button show on the music source that it is working but the music doesnt mute or reduce volume same with the SFX, please help me with a fix
@RehopeGames
10 ай бұрын
This playlist can improve you about Audio in Unity. kzread.info/head/PLf6aEENFZ4FuL4XSo0rEUgecY7FED8p-I And thanks for your nice feedback bro 😊
Changing Scene Destroy's the object though so if you return to that scene again, the music and sfx is gone. Is there a way around that?
@RehopeGames
8 ай бұрын
Hello , Maybe this video give you an idea to you ... kzread.info/dash/bejne/qqerp9KHoNjJirQ.html
a video on camera zoom please, room related to speed like high speed zoom out slow speed zoom in in 2d top to down games please
@RehopeGames
Жыл бұрын
👍 Next Video ...
I have a volume slider in my main menu scene connected to the audio manager which works fine at the start, but if I play the game and return to the main menu scene, the sliders disconnect from my audio manager script, the slider values reset (not volume values) and no longer adjusts the volume. Does anyone know a fix for this?
@RehopeGames
Жыл бұрын
Hello, I think this video can help you kzread.info/dash/bejne/eWF-t9JxcbCrqJM.html
@jackrootsey4085
Жыл бұрын
@@RehopeGames thanks but this unfortunately didn’t solve my problem. The issue I have is on the slider “On Value Changed” where I reference my audio manager, it is no longer referenced when I go back to the main menu, even though my audio manager has don’t destroy on load
do you have tutorial how to do the sound panel?
Adamsın kral eyw. Bi sorum olacaktı. Aynı anda birden fazla SFX de çaldırabilir miyiz?
@RehopeGames
6 ай бұрын
Evet kardeşim bir audio source üzerinden aynı anda birden çok SFX çağırabilirsin 👍
Great tutorial, but just a question. Why not scriptable objects for the clips?
@RehopeGames
8 ай бұрын
Good idea 👌 You can use Dictionary, List, Array or Scriptable object to keep clips. Thanks... 😊
what about playing sfxSound on specific Position? such as meteor hit SFX, the closer i am, the louder the sfx
@RehopeGames
Жыл бұрын
that's good idea , you can do it 😊
@Video-Makers
10 ай бұрын
add the audio source and change its Spatial Blend to 3d and reverb zone mix to 2d and Walla its applied now as Ur character move closer to the object on which u have applied this audio source the louder the sound get the sound will get to its maximum when you are standing in front of it now u play with its setting and then u will get the idea.
My game ain't playing audio I did everything "adding audio to audio source, adding audio listener to scene, I even attached both to the camera I wrote a script to play on start and I check the audio settings in player settings I don't know what's wrong the sounds are playing I tested it, but when I enter play mode no audio"
@RehopeGames
Жыл бұрын
There can be many reasons for this problem. I will share a new video about adding sound to the game in 1 week, maybe that video will help 🙏
how can i paused my sound, when I click the pause button
How can i use playerPrefs to save the volume slider. I mean what should i set the value of the playerPrefs? PlayerPrefs.SetFloat("Volume",??); Can you please explain it here if you don't mind!?
@RehopeGames
Жыл бұрын
Hi 😊 It would be difficult and long to explain in writing. In 1 week, I will share a video about adding sound to the current series. You will find the answer to your question in that video. Thank you so much for your interest 🙏
@ArsalanKhan-xr7mw
Жыл бұрын
Okay. Waiting for your video then. But please make video as soon as possible
@RehopeGames
Жыл бұрын
@@ArsalanKhan-xr7mw 👍
@josephreason6255
Жыл бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AudioController : MonoBehaviour { public Slider _musicSlider, _sfxSlider; private const string MusicVolumeKey = "MusicVolume"; private const string SFXVolumeKey = "SFXVolume"; private void Start() { // Load the saved audio settings LoadAudioSettings(); } public void ToggleMusic() { AudioManager.Instance.ToggleMusic(); } public void ToggleSFX() { AudioManager.Instance.ToggleSFX(); } public void MusicVolume() { AudioManager.Instance.MusicVolume(_musicSlider.value); SaveAudioSettings(); } public void SFXVolume() { AudioManager.Instance.SFXVolume(_sfxSlider.value); SaveAudioSettings(); } private void SaveAudioSettings() { PlayerPrefs.SetFloat(MusicVolumeKey, _musicSlider.value); PlayerPrefs.SetFloat(SFXVolumeKey, _sfxSlider.value); PlayerPrefs.Save(); } private void LoadAudioSettings() { if (PlayerPrefs.HasKey(MusicVolumeKey)) { float musicVolume = PlayerPrefs.GetFloat(MusicVolumeKey); _musicSlider.value = musicVolume; AudioManager.Instance.MusicVolume(musicVolume); } if (PlayerPrefs.HasKey(SFXVolumeKey)) { float sfxVolume = PlayerPrefs.GetFloat(SFXVolumeKey); _sfxSlider.value = sfxVolume; AudioManager.Instance.SFXVolume(sfxVolume); } } } //This Updated Script saves the volume level across play sessions. I haven't figured out saving the mute state yet...
How do you change the music during the game? Since when I attempted to do this, it just stopped the audio.
@RehopeGames
Жыл бұрын
Hello , How can I help you? Did you want to change the music or adjust the volume ?
@rynnguyen2411
Жыл бұрын
@@RehopeGames I want to change the music, so I have one main theme but when I want to change the song it just stops the music audio.
Is transparency controlled by Script?
@RehopeGames
Жыл бұрын
No , I control it by using button event system . ( in inspector panel )
Hi, can I use this script if I want to make the same settings as you, only the controls will be in the Main menu in options?
@uberkull9326
4 ай бұрын
If you watch starting at 1:01 he creates a simple class called Sound. Saving that file in the same location as AudioManager(or project namespace in general), will allow the AudioManger to see the Sound reference in the code.
@honeybadger3643
4 ай бұрын
@@uberkull9326 thanks
7:33Why does your button change transparency when clicked
@RehopeGames
Жыл бұрын
Pressing the button turns off the music completely. I reduced the transparency to show that the music is fully turned off
@lazy2785
Жыл бұрын
@@RehopeGames Is transparency controlled by Script?
4:00
Can it work in every scene?
@RehopeGames
Жыл бұрын
You can prefab it and use it in all scenes.
It will not store settings permanently?
@RehopeGames
Жыл бұрын
You can use PlayerPrefs to store settings permanently.
How to save volume setting for another scene 😢
@RehopeGames
Жыл бұрын
you can use PlayerPrefs , I'm gonna explain it in the next videos...
@sadsdad9258
Жыл бұрын
@@RehopeGames Thankyou❤️
Butona basıldığında interactable kapanmasını göstermemişsin, onu nasıl yaptın?
@RehopeGames
Жыл бұрын
Merhaba, Aslında interactable özelliğini kapatmıyorum. İki adet buton var, renkleri farklı. Birine tıklayınca diğeri aktif alıyor.
Can i ask u how to play 2 sound in one moment.
@RehopeGames
8 ай бұрын
You can use PlayOneShot method for this.
Where to downloads your sounds?
@RehopeGames
Жыл бұрын
artlist.io
@AhmadRaza-ph9dv
Жыл бұрын
@@RehopeGames it's free to you live game?
@RehopeGames
Жыл бұрын
@@AhmadRaza-ph9dv No, I got a license for the music.
@AhmadRaza-ph9dv
Жыл бұрын
@@RehopeGames okay thanks
In audioManager I can't find name of sounds to enter value
@RehopeGames
Жыл бұрын
maybe this video can help you kzread.info/dash/bejne/gGyryq9qd82uZNo.html
@thobraa
4 ай бұрын
Try removing : monobehaviour from your sound class (script). So it says "public class Sound" instead of "public class Sound : Monobehaviour"
Is it a tutorial or a speedrun lost unity beginner any%
@RehopeGames
Жыл бұрын
Thank you for your feedback. I will consider
How about Master volume
@RehopeGames
Жыл бұрын
Sorry ! Can you elaborate on your question?
@NT-rz3nf
Жыл бұрын
@@RehopeGames I mean can you do How to make Master Volume, In this video, there are Music Volume and SFX Volume. If we have master volume we can change music and SFX volume in 1 time. sorry for my bad english.
@RehopeGames
Жыл бұрын
@@NT-rz3nf now i understand you . if you want to control all sound with one setting, you can use a single Audio Source. you can play music and sound effects from the same Audio source
SRP
@RehopeGames
8 ай бұрын
🤔
what a frustrantingly bad tutorial to follow
@RehopeGames
Жыл бұрын
This is the first devastating critical comment I've ever received. I am new to KZread and I continue to improve my English. If you can give a concrete example of what you don't like about the video, I can take it into account to improve myself.
@NobSwitch
Жыл бұрын
@@RehopeGames Hello - I am very sorry for the rude comment above. I was trying to find an Audio Manager tutorial and was frustrated that this was not working. I see that your post was only four months ago so it didn't make sense that your version was not working with mine. Anyway - two things I would say, you move on way too fast without explaining what you are doing, and the background music is not needed. I hope my comment didn't make you feel down, you are obviously very intelligent when it comes to unity and c# and your english is just fine. I wish you a wonderful day.
@RehopeGames
Жыл бұрын
Thank you for your kindness, I wish you luck in making the game.
I appreciate your time on this video, but this seems more like a reference for someone who is very familiar with Unity already. There is no explanation on what the methods are, or why they work. The video is way to quick.
@RehopeGames
Жыл бұрын
Thanks for the feedback, I will consider
didn't work for me
@RehopeGames
8 ай бұрын
I hope you solved it. Can you give me more detail ?