Currently, I use this code to play 2d sound (just play a 3d sound at the camera, just because I don’t need a 3d sound in this case)
public AudioClip pGameOver = null;
//...
AudioSource.PlayClipAtPoint(pGameOver, Camera.main.transform.position);
I don’t know if it’s better (in performance favor) to use the static function AudioSource.PlayClipAtPoint()
instead of creating an AudioSource
to call its Play()
function. Obviously, in the first option, I can’t play 2d sound (I think), but if I use the second option I can play 2d sound. But I think the first option is more safe because I can play multiple sounds.
So how to optimize optimize performance for audio when I don’t need 3D audio effect? All I need is playing a wav file as it is.
My target platform is Android.