ValveSoftware / steam-audio

Steam Audio
https://valvesoftware.github.io/steam-audio/
Apache License 2.0
2.2k stars 152 forks source link

[Unity] Performance improvement on SteamAudioManager.GetPerspectiveCorrection #296

Closed Chrisdbhr closed 5 months ago

Chrisdbhr commented 5 months ago

The problem

the method GetPerspectiveCorrection() in SteamAudioManager is called every LateUpdate() even when perspectiveCorrection is disabled in SteamAudioSettings and inside it there are multiple calls to Camera.main, this method searches for the first game object with the "MainCamera" tag, with can lead to performance issues on scenes with a lot of game objects, as shown bellow.

image

Solution implemented

lakulish commented 5 months ago

There should probably be a NotifyMainCameraChanged function just like NotifyAudioListenerChanged, so that the cached Camera instance can be updated if it is explicitly changed by some script.