|
Post by Necka on May 15, 2022 14:05:24 GMT
Hello, 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 Necka on May 15, 2022 14:06:16 GMT
Oh, sorry for the formatting of my post here. I have issues to login with my account here so I posted as guest and can't edit
|
|
|
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?
-B
|
|
|
Post by Necka on May 15, 2022 15:31:34 GMT
Thanks for the fast answer (and on a Sunday!) Yes, grabbing the first and only variation would be perfect for my use case
|
|
|
Post by DarkTonic Dev on May 15, 2022 16:57:40 GMT
Cool, this should do the trick:
var variation = MasterAudio.GrabGroup("Arrow").groupVariations[0];
|
|
|
Post by Necka on May 15, 2022 17:28:22 GMT
Cool, this should do the trick: var variation = MasterAudio.GrabGroup("Arrow").groupVariations[0];
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.
|
|
|
Post by DarkTonic Dev on May 15, 2022 20:07:09 GMT
No, you can't get any of that at edit time the same way. We haven't any equivalent that works in edit mode. If you really need it, I can send you some code but it won't be a one liner.
|
|
|
Post by Necka on May 15, 2022 21:02:31 GMT
Don't worry, it's fine I don't think it's going to be a problem for this use case, at least I have a way to get the variation properties easily now  Thanks a lot again!
|
|
|
Post by DarkTonic Dev on May 15, 2022 21:40:57 GMT
Ok, thanks.
|
|