bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on May 27, 2023 15:47:44 GMT
I play audio clips via code, eg: MasterAudio.PlaySound3DAtTransform("MySoundgroupName", this.transform);
I was assuming the Clip ID field is used as an alias but I can't get this to work, I get no sound.
I have a soundgroup with 6 clips for variation, is there a way to name that group by a single string so I can use that as the name instead of the name it gets when adding the first clip?
|
|
|
Post by DarkTonic Dev on May 27, 2023 21:15:15 GMT
If you get no sound, it's probably just too quiet to hear because it's too far away from the Listener. Try flipping the Master Audio Mixer to Spatial Blend Rule to "Force to 2d" to check before proceeding.
You can always rename the Sound Group in the Hierarchy Window to whatever you like.
|
|
bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on Jun 3, 2023 17:38:11 GMT
I've tried several things that don't work. Is there any documentation that shows the exact steps required to set up a sound group with variations that you can call by a custom string name?
The only way I can get a group variation to play is by using the first name it shows in the MA inspector when the first sound clip is added.
My steps that work: - Drag 1 clip as new sound group - Select new group gameobject in heirarchy - Drag in more sound clip variations - Call in code. eg: MasterAudio.PlaySound3DAtTransform("Name of first clip in MA inspector", this.transform);
From there, how do I use a custom string name to call the group?
ClipID doesn't work. Changing the gameobject in the inspector doesn't work.
Perhaps along with that question, is there any debug/logging to indicate that the clip named in the call to PlaySound3DAtTransform() doesn't exist or wasn't found?
|
|
|
Post by DarkTonic Dev on Jun 3, 2023 18:45:50 GMT
I've tried several things that don't work. Is there any documentation that shows the exact steps required to set up a sound group with variations that you can call by a custom string name? The only way I can get a group variation to play is by using the first name it shows in the MA inspector when the first sound clip is added. My steps that work: - Drag 1 clip as new sound group - Select new group gameobject in heirarchy - Drag in more sound clip variations - Call in code. eg: MasterAudio.PlaySound3DAtTransform("Name of first clip in MA inspector", this.transform);
From there, how do I use a custom string name to call the group? ClipID doesn't work. Changing the gameobject in the inspector doesn't work.
Perhaps along with that question, is there any debug/logging to indicate that the clip named in the call to PlaySound3DAtTransform() doesn't exist or wasn't found?
If you want to play a particular variation by name or alias, that's a different optional parameter, that you didn't use in your code sample. The name of the Sound Group is still required, which you can change in the Hierarchy window if you like. Sound Group names must be unique, but it's perfectly fine to have a Variation name duplicated in different Sound Groups. So the following code would play a Variation named (or aliased with) "LouderSurprise" in Sound Group "Treasure". MasterAudio.PlaySound3DAtTransform("Treasure", this.transform, 1f, null, 0f, "LouderSurprise");
Yes, if "LouderSurprise" variation doesn't exist, the Console window will tell you so. You may need to turn on "Log Sounds" for the Sound Group to see some of those types of messages though.
|
|
bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on Jun 5, 2023 11:51:49 GMT
I'm not trying to play a variation by name, I'm trying to play the sound group by name, and that sound group has variations.
Changing the game object name in the hierarchy doesn't work for me.
|
|
|
Post by DarkTonic Dev on Jun 5, 2023 13:24:04 GMT
What's your Unity version? I will try it in mine.
|
|
bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on Jun 9, 2023 12:53:32 GMT
What's your Unity version? I will try it in mine. v2021.3.10f1/BIRP
|
|
|
Post by DarkTonic Dev on Jun 9, 2023 16:41:56 GMT
I just did a test where I renamed a Sound Group in Hierarchy to "Garbage" and my hard-coded line of code was able to play it when I hit play.
MasterAudio.PlaySound3DAtTransformAndForget("Garbage", this.transform);
Am I not doing the right steps?
|
|
bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on Jun 22, 2023 14:26:39 GMT
I tried it again and it seems to be working. What was perhaps confusing me is when you change the gameobject name in the hierarchy, it doesn't reflect the change in the inspector right away.
Either way, it does work for me now, thanks.
|
|
|
Post by DarkTonic Dev on Jun 22, 2023 17:46:22 GMT
It did change the name in the Inspector right away for me. I wonder what the difference is here?
|
|