OSVR / OSVR-Unity

Package for authoring OSVR experiences with Unity.
Apache License 2.0
98 stars 38 forks source link

Don't add AudioListener unless there are none in the scene #195

Closed DuFF14 closed 7 years ago

DuFF14 commented 7 years ago

https://github.com/OSVR/OSVR-Unity/blob/master/OSVR-Unity/Assets/OSVRUnity/src/DisplayController.cs#L265

if (vrViewer.GetComponent<AudioListener>() == null)
{
     vrViewer.AddComponent<AudioListener>(); //add an audio listener
}

should be

if (FindObjectOfType<AudioListener>() == null)
{
     vrViewer.AddComponent<AudioListener>(); //add an audio listener
}

There is a memory leak if two audio listeners are in the scene.