Search Unity

Question Music Playing without any Audio Source

Discussion in 'Audio & Video' started by omgtntlol101, Jun 14, 2021.

  1. omgtntlol101

    omgtntlol101

    Joined:
    Jun 2, 2019
    Posts:
    1
    When I play my project in edit mode (not build), I hear background music, but I don't have any audio sources in the scene. I've checked every script and object but couldn't figure out where it's coming from, and deleted and reimported the audio clips even with different names, to no avail. Any ideas as how I should stop the music?
     
  2. You either find out what asset do the sound or if it isn't a problem, you can just mute it in the toolbar:
    https://docs.unity3d.com/Manual/ViewModes.html Mute audio is next to the "light" button.
     
  3. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    you have autoplay turned on in the inspector
     
  4. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    Drag this script onto a gameobject in your scene, and it will highlight all the gameobjects in the hierarchy that have audiosource components. Unless the audiosource components are added, played and destroyed faster than the checks happen, but that shouldn't be applicable in this case.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using UnityEngine;
    5. using UnityEditor;
    6.  
    7. public class FindAllAudiosources : MonoBehaviour
    8. {
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         StartCoroutine(PingInHierarchy<AudioSource>());
    13.     }
    14.  
    15.     private IEnumerator PingInHierarchy<T>() where T: Object
    16.     {
    17.         while (true)
    18.         {
    19.             List<T> objectsToPing = GameObject.FindObjectsOfType<T>().ToList();
    20.  
    21.             foreach (var obj in objectsToPing)
    22.             {
    23.                 EditorGUIUtility.PingObject(obj);
    24.                 yield return new WaitForSeconds(1f);
    25.             }
    26.  
    27.             yield return new WaitForSeconds(1f);
    28.         }
    29.     }
    30. }
    31.  
     
    Last edited: Jun 15, 2021
  5. DriesVienne

    DriesVienne

    Joined:
    Jun 22, 2013
    Posts:
    27