public static Transform InitAudioSourceFollower(Transform transToFollow, string followerName, string soundGroupName, string variationName, bool willFollowSource, bool willPositionOnClosestColliderPoint, bool useTopCollider, bool useChildColliders, MasterAudio.AmbientSoundExitMode exitMode, float exitFadeTime) { if (ListenerFollower == null || FollowerHolder == null) { return(null); } var grp = MasterAudio.GrabGroup(soundGroupName); if (grp == null) { return(null); } if (grp.groupVariations.Count == 0) { return(null); } var triggerRadius = grp.groupVariations[0].VarAudio.maxDistance; var follower = new GameObject(followerName); var existingDupe = FollowerHolder.GetChildTransform(followerName); if (existingDupe != null) { GameObject.Destroy(existingDupe.gameObject); } follower.transform.parent = FollowerHolder; follower.gameObject.layer = FollowerHolder.gameObject.layer; var followerScript = follower.gameObject.AddComponent <TransformFollower>(); followerScript.StartFollowing(transToFollow, soundGroupName, variationName, triggerRadius, willFollowSource, willPositionOnClosestColliderPoint, useTopCollider, useChildColliders, exitMode, exitFadeTime); _transformFollowers.Add(followerScript); return(follower.transform); }
public static Transform InitAudioSourceFollower(Transform transToFollow, string followerName, string soundGroupName, bool willFollowSource) { if (ListenerFollower == null || FollowerHolder == null) { return(null); } var grp = MasterAudio.GrabGroup(soundGroupName); if (grp == null) { return(null); } if (grp.groupVariations.Count == 0) { return(null); } var triggerRadius = grp.groupVariations[0].VarAudio.maxDistance; var follower = new GameObject(followerName); var existingDupe = FollowerHolder.GetChildTransform(followerName); if (existingDupe != null) { GameObject.Destroy(existingDupe.gameObject); } follower.transform.parent = FollowerHolder; follower.gameObject.layer = FollowerHolder.gameObject.layer; var followerScript = follower.gameObject.AddComponent <TransformFollower>(); followerScript.StartFollowing(transToFollow, soundGroupName, triggerRadius, willFollowSource); return(follower.transform); }
public static Transform InitAudioSourceFollower(Transform transToFollow, string followerName, string soundGroupName, string variationName, float volume, bool willFollowSource, bool willPositionOnClosestColliderPoint, bool useTopCollider, bool useChildColliders, MasterAudio.AmbientSoundExitMode exitMode, float exitFadeTime, MasterAudio.AmbientSoundReEnterMode reEnterMode, float reEnterFadeTime) { #if !PHY3D_ENABLED return(null); // there is no Ambient Sound script functionality without Physics. #else if (ListenerFollower == null || FollowerHolder == null) { return(null); } var grp = MasterAudio.GrabGroup(soundGroupName); if (grp == null) { return(null); } if (grp.groupVariations.Count == 0) { return(null); } SoundGroupVariation variation = null; if (!string.IsNullOrEmpty(variationName)) { variation = grp.groupVariations.Find(delegate(SoundGroupVariation v) { return(v.name == variationName); }); if (variation == null) { Debug.LogError("Could not find Variation '" + variationName + "' in Sound Group '" + soundGroupName); return(null); } } else { variation = grp.groupVariations[0]; } var triggerRadius = variation.VarAudio.maxDistance; var follower = new GameObject(followerName); var existingDupe = FollowerHolder.GetChildTransform(followerName); if (existingDupe != null) { GameObject.Destroy(existingDupe.gameObject); } follower.transform.parent = FollowerHolder; follower.gameObject.layer = FollowerHolder.gameObject.layer; var followerScript = follower.gameObject.AddComponent <TransformFollower>(); followerScript.StartFollowing(transToFollow, soundGroupName, variationName, volume, triggerRadius, willFollowSource, willPositionOnClosestColliderPoint, useTopCollider, useChildColliders, exitMode, exitFadeTime, reEnterMode, reEnterFadeTime); _transformFollowers.Add(followerScript); return(follower.transform); #endif }