Search Unity

Adding audio source to prefab issue...

Discussion in 'Getting Started' started by RocketTG, Jun 7, 2017.

  1. RocketTG

    RocketTG

    Joined:
    Jun 6, 2017
    Posts:
    3
    Hi there!

    I just recently started using unity and ran into a weird issue. During the Space Shooter tutorial I was clipping along and got to the audio section. He said one of the nice features available is to drag an audio file into a prefab or game object and have it automatically create an audio source and reference to it. Well I tried doing that by dragging, for example, the asteroid explosion audio file into the asteroid explosion prefab and it just created a copy of the audio file in the hierarchy. However, when I try to add background music to the Game Controller game object located in the hierarchy, it works fine and adds the audio source and reference just like it is supposed to. Anyone know what's going on?

    Thanks!
     
  2. mahmoudsali

    mahmoudsali

    Joined:
    Jul 11, 2017
    Posts:
    1
    I ran into the same issue. I had to drag the explosion_asteroid into the hierarchy making an instance, then adding the explosion_audio to that instance. After that get focus on the created instance and you will see a prefab tab, click apply and the prefab will be updated. Finally delete the instance.
     
  3. xnick_u

    xnick_u

    Joined:
    Oct 23, 2017
    Posts:
    1
    Same thing happening to me. I'm Adding the components instead of dragging...
     
  4. RomainLaporte

    RomainLaporte

    Joined:
    Dec 15, 2017
    Posts:
    2
    Hi everyone,
    I have exactly the same issue. Mahmoudsali's tweak works but I would like to know why the drag and drop on prefabs do not work like in the Space Shooter tutorial.
    Thanks.
    (version 2017.3.0f1 on Ubuntu 16.04)
     
    unity_EldXCIpnDNv7Ow likes this.
  5. unity_EldXCIpnDNv7Ow

    unity_EldXCIpnDNv7Ow

    Joined:
    Dec 30, 2017
    Posts:
    1
    I have the same problem on Windows 10 (Unity 2017.2 1f1)

    Select the Prefab (e.g. explosion_asteroid) in the Project.
    In the Inspector click on Add Component.
    Select Audio >> Audio Source.
    Then drag audio clip (explosion_asteroid) to Audio Clip.

    This worked for me and there were no instances made in Hierarchy.
     
    Storm_2 likes this.
  6. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    114
    I just want to say, I'm having the same issue as well with audio clips and prefabs. The dragging, dropping, and auto setup is nice stuff inside of Unity. Seeing it work in the Space Shooter tutorial, but not on 2017.2.1f1, this definitely seems like a bug.
     
  7. flittnerj

    flittnerj

    Joined:
    Jan 18, 2018
    Posts:
    1
    I got it working in Unity 2017.3.0f3 in the shooter tutorial by going to the add component section of the Inspector of the explosion_asteroid prefab, and then dragging the explosion_asteroid audio to the box next to Audio Clip at the top of the Audio Source window in the Inspector.
     
  8. vagnerr

    vagnerr

    Joined:
    Feb 15, 2018
    Posts:
    1
    Looks like its still an issue in "2017.3.1f1 Personal"

    If you drag and drop the audio onto the prefab rather than add that correctly to prefab as expected it creates an empty "explosion_player" object in the Hierarchy with an audio source on it rather than creating it all on the prefab.

    The work around is basically still the manual process mentioned by others of Adding the Audio Source to the prefab, then setting the Audio Clip.
     
  9. ShashankSahu0

    ShashankSahu0

    Joined:
    Mar 19, 2018
    Posts:
    1
    I am using unity 2017.3.1f1 and there also same issue can be seen .
    It wasted me a hour to two to solve the problem and i solved it by landing on this page.
    So for future readers here is the way to attach a audio source.

    Assuming you are following space shooter tutorial.

    If you want to add sound to explosion_asteroid Vfx
    select explosion_asteroid VFX and then click on ADD COMPONENT in the Inspector.
    Then select Audio >Audio Source
    It will then add a audio source then simple drag the explosion_asteroid audio to the audio clip field and you are done.