Комментарии:
Do you normally play your sounds through code or instantiate a prefab?
ОтветитьLast Question, does anyone know if Button_UI has been replaced by just the Button class. Unity gives me a namespace error when I try to use Button_UI despite having the include UnityEngine.UI;
ОтветитьDoes this solution allow for multiple overlapping audio clips? Is there any point in having and audio source component specific to each object that makes the noise?
Ответитьin the function playsound(), you instantiate a game object to attach a AudioSource component, is there a benefit to doing it like this rather than just adding a audioSource component to SoundManager entity and referencing that in Soundamanager.cs and using that again and again everytime the function gets called?
ОтветитьThanks a lot man
ОтветитьWorks great! Only issue is that when the new sound object is instantiated it remains in the hierarchy, even after its played. Is there a way to destroy it easily after it plays if it's just a one-off sound?
ОтветитьDo you know of a way to get the cover art of an audio file from a script to display it in a Sprite?
ОтветитьIf anyone got ArgumentException, create folder named 'Resources' and add GameAssets prefab to it.
ОтветитьThank you for this great tutorial. Unfortunately, I get the error "The Object you want to instantiate is null".
I put my audio files inside a file called Resources/AudioAssets and wrote the following:
Instantiate(Resources.Load<AudioAssets>("AudioAssets"));
What am i doing wrong ? Does this only work with "GameAssets" ?
How does this code work actually ? How does it go to the assigned sound file exactly ? A bit more information would be very helpful.
Thanks for this tutorial. Regards,
Could you make a tutorial on object pooling these sounds?
Ответитьwhat about a sound that repeats 1000 times? how do you deal with that extra 1000 gameObject that you created? you don't mention it at all
ОтветитьAs always amazing tutorial (I love your tutorials) - I think on this one though it didn't answer the "why build it" - why is it more efficient and better to have a sound manager? Sorry and hope it sounds like a complaint (is not really) But I always think it id good to know why an approach is needed and why to build something. - love your work a lot!!
ОтветитьConsol shows me "NullReferenceException: Object reference not set to an instance of an object". Sound objects generate but no sound. What could be the reason?
ОтветитьI cannot figure this out. Using this method, is there a way I can set different clips to have different component values??
I have audio that works essentially how I want, but I wanted to modify the code a bit, and it is just not working how I want, I hope the code explains enough. The if statement I isolated is the issue. I want the loop value to be true when the Level1Music clip is created.
if (CanPlaySound(sound))
{
GameObject soundGameObject = new GameObject("Sound");
soundGameObject.transform.position = position;
AudioSource audioSource = soundGameObject.AddComponent<AudioSource>();
audioSource.clip = GetAudioClip(sound);
Debug.Log(soundGameObject.GetComponent<AudioSource>().clip);
if (audioSource.clip.Equals(Sound.Level1Music))
{
soundGameObject.GetComponent<AudioSource>().loop = true;
}
audioSource.Play();
Object.Destroy(soundGameObject, audioSource.clip.length);
}
}
Where the hell do you put the GameAssets thing on everything or what ????????????
ОтветитьIsn't it better to create all audio sources for all sounds at the start? So dont need to create a new object everytime i want to play a sound. So it takes RAM instead of CPU.
ОтветитьDebug.Log(GameAssets.i.playerAttack); is null and Im not sure why.
ОтветитьWon't this create a new GameObject in the scene every time you play a sound?
ОтветитьResources.Load<something>("smth") is null??
Ответитьwtf? class in class? you are creating a nightmare...
Ответить