For starters, I'm using C#.
I have an AudioMixer class, which is a MonoBehaviour, and in which I've defined a static method:
There is an instance of the AudioMixer in the scene. Objects in the scene trigger sounds by doing:
This works fine as long as I don't change scenes. But if I start scene A, and then from scene A load into scene B, then in scene B I get a very odd behavior: the "name" parameter of AudioMixer.PlaySound is always an empty string, regardless of what was passed in.
So here's a call:
And here's the parameter validation in AudioMixer.PlaySound:
And I'll see a sequence of log messages like this:
I am totally mystified by this behavior. :o
If I start scene B directly, it works. This isn't an issue with the scene configuration itself, or the configuration of that specific AudioMixer instance. The problem seems to be related to destroying one AudioMixer (the one in scene A) and then creating another one (the one in scene B) and then accessing the second one via a static method call.
Is there something about static methods' behavior that I'm just flat-out missing?
asked Feb 14 '12 at 03:28 AM