I'm having an issue with MasterAudio (MA 2022, latest version from the store). I'm using Unity 2022.1.0 here.
I need to be able to grab in Editor and also at Runtime, the length of a sound.
So I'll keep it simple. I use this debug command, where "SoundToPlay" is a string (decorated with [SoundGroup] to avoid errors).
Debug.Log(MasterAudio.GetNextVariationForSoundGroup(SoundToPlay)); The result of this is always null. In Editor and at Runtime. Here's the sound group, there are no variant, just the default one in that case and I'd like to grab it from code and get the audio length etc.
MasterAudio works otherwise, if I use PlaySound... using the same string, it plays the sound properly.
At first I thought it was because I renamed my sound groups but I tried in this example just adding this sound group and not renaming it or touching anything, the result is the same.
Post by DarkTonic Dev on May 15, 2022 15:29:15 GMT
Well, GetNextVariationForSoundGroup is behaving correctly. It asks the randomizer for the Sound Group for the next variation in it's random pool, but it can't refill the pool as that would be destructive to the current pool.
Since you only have 1 Variation, there is never a "next" variation in the pool, it always has to refill after every play.
Would grabbing the first and only Variation get you what you need?
Cool, this should do the trick: var variation = MasterAudio.GrabGroup("Arrow").groupVariations;
Ok so this works at runtime, thanks a lot
Is there any chance to be able to grab this at editor time?
At editor time I get the error: "Could not grab Sound Group 'Power_AirRelease' because it does not exist in this scene."
Background: I'm using an asset called "Feel" from MoreMountain. While they do have a lot around audio management I prefer to work only with MasterAudio. I'm creating a custom Feel feedback, and there is an option basically that the feedback get the audio length to then sequence other feedback after it if needed (like play that sound, when it's over, play those particle effects)
So, long story short, I just need if it's possible to find a way to get the audio length in editor.
If it's impossible I'll just pop an "If UnityEditor" constraint as it will anyway work at runtime but it's nicer to see values during dev time.