friend
New Member
Posts: 4
Posts: 4
|
Post by friend on Aug 13, 2015 18:52:40 GMT
I am currently working on a project where we have many dynamic sound groups with only one sound in them. I plan on implementing a feature that will require the panning of some 2d sounds, and to do this I believe I need to use Audiosource.pan on the audiosource associated with the sound group (we are using unity 4 still). I am able to access the dynamic sound group easily, and have gotten that part in my script, but I am unsure of how to get to the Audiosource from there. It looks like it would be in the DynamicGroupVariation list (groupVariations) but in the comments of the DynamicSoundGroup code it says that that list is used for the inspector only.
How do i get to the audiosource from a dynamic sound group?
|
|
friend
New Member
Posts: 4
Posts: 4
|
Post by friend on Aug 13, 2015 19:56:00 GMT
was able to do it via getcomponentinchildren.
|
|
|
Post by DarkTonic Dev on Aug 14, 2015 3:43:24 GMT
The comments are correct. There is no reason to get the Audio Source of the Dynamic Sound Group. As soon as the game object is enabled, it copies all its settings over to a new child of the Master Audio game object and the Dynamic SGC game object stuff is no longer used.
If you want to access the Audio Source of a Sound Group Variation, you do something like this (have to play it first):
var psr = MasterAudio.PlaySound3DAtTransform("Arrow", transform); if (psr.ActingVariation != null){ psr.ActingVariation.VarAudio.bypassEffects = true; // set the bypass effects flag on the Audio Source. }
Note that you should never set the volume or pitch of an Audio Source like this because that will "go around" Master Audio. But if you want to switch other properties, that should be ok.
By the way, this example code and more is in the readme.
|
|