Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

"Delete all of the calls to PlaySound" - In need of Untiy with FMOD help!

Discussion in 'Scripting' started by Aleks_Oz, Nov 8, 2020.

  1. Aleks_Oz

    Aleks_Oz

    Joined:
    Nov 8, 2020
    Posts:
    5
    Hi everyone, hope you're all well?

    I'm a music producer / composer who is completely new to coding and I'm currently trying to learn FMOD for professional reasons.

    I'm doing a tutorial for integrating Unity with FMOD at the moment, it's for the "Karting Microgame". All was well until I came across an instruction which said:

    " 42. Delete all of the calls to PlaySound. "

    In my Code editor, I found a bunch of code which says:

    void PlaySound(AudioClip sound)
    {
    if (!sound)
    return;

    if (!m_AudioSource)
    {
    m_AudioSource = gameObject.AddComponent<AudioSource>();
    m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDObjective);
    }

    m_AudioSource.PlayOneShot(sound);

    How exactly do I delete this "call"? It doesn't seem as straight forward as just deleting lines which have a certain word, which I was instructed to do up until now?

    If anyone can help, that'd be greatly appreciated!

    Thanks,

    Aleks
     
  2. Aleks_Oz

    Aleks_Oz

    Joined:
    Nov 8, 2020
    Posts:
    5
    Hi guys, doesn't anyone at all know what the solution to this could be?

    Seeing as it's from a beginner's tutorial it should be pretty simple to anyone on here? I can't proceed further if I can't do this step though.

    Any help or suggestions would be greatly appreciated!
     
  3. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    Well , that here:

    Code (CSharp):
    1. void PlaySound(AudioClip sound)
    2. {
    3. if (!sound)
    4. return;
    5.  
    6. if (!m_AudioSource)
    7. {
    8. m_AudioSource = gameObject.AddComponent<AudioSource>();
    9. m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDObjective);
    10. }
    11.  
    12. m_AudioSource.PlayOneShot(sound);
    is the function, "calls" are either other functions which call the "PlaySound" function or he means the last line which tells the AudioSource Component to play the sound

    Code (CSharp):
    1. m_AudioSource.PlayOneShot(sound);
     
    Aleks_Oz likes this.
  4. Aleks_Oz

    Aleks_Oz

    Joined:
    Nov 8, 2020
    Posts:
    5
    Thanks Terraya, I'll try and look into this more - I appreciate the response!
     
    Terraya likes this.
  5. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    There are calls to PlaySound on lines 87 and 117.
     
    Itaya_Music and Aleks_Oz like this.
  6. Aleks_Oz

    Aleks_Oz

    Joined:
    Nov 8, 2020
    Posts:
    5
    Thanks for responding! Oh right, so I simply delete all the text on those particular lines?
     
  7. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    Yes, delete Line 87: PlaySound(completedSound); and Line 117: PlaySound(initSound);
     
    Itaya_Music and Aleks_Oz like this.
  8. Aleks_Oz

    Aleks_Oz

    Joined:
    Nov 8, 2020
    Posts:
    5
    Thanks Valjuin - much appreciated!
     
  9. Itaya_Music

    Itaya_Music

    Joined:
    Jul 5, 2021
    Posts:
    1
    Thank you!!!