/// <summary> /// This method will create the Sound Groups, Variations, buses, ducking triggers and Playlist objects specified in the Dynamic Sound Group Creator's Inspector. It is called automatically if you check the "Auto-create Items" checkbox, otherwise you will need to call this method manually. /// </summary> public void CreateItems() { if (hasCreated) { Debug.LogWarning("DynamicSoundGroupCreator '" + this.transform.name + "' has already created its items. Cannot create again."); return; } var ma = MasterAudio.Instance; if (ma == null) { return; } PopulateGroupData(); for (var i = 0; i < groupBuses.Count; i++) { var aBus = groupBuses[i]; if (aBus.isExisting) { var confirmBus = MasterAudio.GrabBusByName(aBus.busName); if (confirmBus == null) { MasterAudio.LogWarning("Existing bus '" + aBus.busName + "' was not found, specified in prefab '" + this.name + "'."); } continue; // already exists. } if (!MasterAudio.CreateBus(aBus.busName)) { continue; } var createdBus = MasterAudio.GrabBusByName(aBus.busName); if (createdBus == null) { continue; } createdBus.volume = aBus.volume; createdBus.voiceLimit = aBus.voiceLimit; createdBus.isMonoBus = aBus.isMonoBus; } for (var i = 0; i < groupsToCreate.Count; i++) { var aGroup = groupsToCreate[i]; var busName = string.Empty; var selectedBusIndex = aGroup.busIndex == -1 ? 0 : aGroup.busIndex; if (selectedBusIndex >= HardCodedBusOptions) { var selectedBus = groupBuses[selectedBusIndex - HardCodedBusOptions]; busName = selectedBus.busName; } aGroup.busName = busName; var groupTrans = MasterAudio.CreateNewSoundGroup(aGroup, this.trans.name); // remove fx components for (var v = 0; v < aGroup.groupVariations.Count; v++) { var aVar = aGroup.groupVariations[v]; if (aVar.LowPassFilter != null) { GameObject.Destroy(aVar.LowPassFilter); } if (aVar.HighPassFilter != null) { GameObject.Destroy(aVar.HighPassFilter); } if (aVar.DistortionFilter != null) { GameObject.Destroy(aVar.DistortionFilter); } if (aVar.ChorusFilter != null) { GameObject.Destroy(aVar.ChorusFilter); } if (aVar.EchoFilter != null) { GameObject.Destroy(aVar.EchoFilter); } if (aVar.ReverbFilter != null) { GameObject.Destroy(aVar.ReverbFilter); } } if (groupTrans == null) { continue; } groupsToRemove.Add(groupTrans); } for (var i = 0; i < musicDuckingSounds.Count; i++) { var aDuck = musicDuckingSounds[i]; if (aDuck.soundType == MasterAudio.NO_GROUP_NAME) { continue; } MasterAudio.AddSoundGroupToDuckList(aDuck.soundType, aDuck.riseVolStart); } for (var i = 0; i < customEventsToCreate.Count; i++) { var anEvent = customEventsToCreate[i]; MasterAudio.CreateCustomEvent(anEvent.EventName); } for (var i = 0; i < musicPlaylists.Count; i++) { var aPlaylist = musicPlaylists[i]; MasterAudio.CreatePlaylist(aPlaylist); } hasCreated = true; }
/// <summary> /// This method will create the Sound Groups, Variations, buses, ducking triggers and Playlist objects specified in the Dynamic Sound Group Creator's Inspector. It is called automatically if you check the "Auto-create Items" checkbox, otherwise you will need to call this method manually. /// </summary> public void CreateItems() { if (_hasCreated) { Debug.LogWarning("DynamicSoundGroupCreator '" + transform.name + "' has already created its items. Cannot create again."); return; } var ma = MasterAudio.Instance; if (ma == null) { return; } PopulateGroupData(); // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < groupBuses.Count; i++) { var aBus = groupBuses[i]; if (aBus.isExisting) { var confirmBus = MasterAudio.GrabBusByName(aBus.busName); if (confirmBus == null) { MasterAudio.LogWarning("Existing bus '" + aBus.busName + "' was not found, specified in prefab '" + name + "'."); } continue; // already exists. } if (!MasterAudio.CreateBus(aBus.busName, errorOnDuplicates)) { continue; } var createdBus = MasterAudio.GrabBusByName(aBus.busName); if (createdBus == null) { continue; } var busVol = PersistentAudioSettings.GetBusVolume(aBus.busName); if (!busVol.HasValue) { createdBus.volume = aBus.volume; } createdBus.voiceLimit = aBus.voiceLimit; createdBus.stopOldest = aBus.stopOldest; #if UNITY_5 createdBus.mixerChannel = aBus.mixerChannel; #endif } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _groupsToCreate.Count; i++) { var aGroup = _groupsToCreate[i]; var busName = string.Empty; var selectedBusIndex = aGroup.busIndex == -1 ? 0 : aGroup.busIndex; if (selectedBusIndex >= HardCodedBusOptions) { var selectedBus = groupBuses[selectedBusIndex - HardCodedBusOptions]; busName = selectedBus.busName; } aGroup.busName = busName; var groupTrans = MasterAudio.CreateNewSoundGroup(aGroup, _trans.name, errorOnDuplicates); // remove fx components // ReSharper disable ForCanBeConvertedToForeach for (var v = 0; v < aGroup.groupVariations.Count; v++) { // ReSharper restore ForCanBeConvertedToForeach var aVar = aGroup.groupVariations[v]; if (aVar.LowPassFilter != null) { Destroy(aVar.LowPassFilter); } if (aVar.HighPassFilter != null) { Destroy(aVar.HighPassFilter); } if (aVar.DistortionFilter != null) { Destroy(aVar.DistortionFilter); } if (aVar.ChorusFilter != null) { Destroy(aVar.ChorusFilter); } if (aVar.EchoFilter != null) { Destroy(aVar.EchoFilter); } if (aVar.ReverbFilter != null) { Destroy(aVar.ReverbFilter); } } if (groupTrans == null) { continue; } _groupsToRemove.Add(groupTrans); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < musicDuckingSounds.Count; i++) { var aDuck = musicDuckingSounds[i]; if (aDuck.soundType == MasterAudio.NoGroupName) { continue; } MasterAudio.AddSoundGroupToDuckList(aDuck.soundType, aDuck.riseVolStart); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < customEventsToCreate.Count; i++) { var anEvent = customEventsToCreate[i]; MasterAudio.CreateCustomEvent(anEvent.EventName, anEvent.eventReceiveMode, anEvent.distanceThreshold, errorOnDuplicates); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < musicPlaylists.Count; i++) { var aPlaylist = musicPlaylists[i]; MasterAudio.CreatePlaylist(aPlaylist, errorOnDuplicates); } _hasCreated = true; if (itemsCreatedEventExpanded) { MasterAudio.FireCustomEvent(itemsCreatedCustomEvent, _trans.position); } }
/// <summary> /// This method will create the Sound Groups, Variations, buses, ducking triggers and Playlist objects specified in the Dynamic Sound Group Creator's Inspector. It is called automatically if you check the "Auto-create Items" checkbox, otherwise you will need to call this method manually. /// </summary> public void CreateItems() { if (_hasCreated) { Debug.LogWarning("DynamicSoundGroupCreator '" + transform.name + "' has already created its items. Cannot create again."); return; } var ma = MasterAudio.Instance; if (ma == null) { return; } PopulateGroupData(); // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < groupBuses.Count; i++) { var aBus = groupBuses[i]; if (aBus.isExisting) { var confirmBus = MasterAudio.GrabBusByName(aBus.busName); if (confirmBus == null) { MasterAudio.LogWarning("Existing bus '" + aBus.busName + "' was not found, specified in prefab '" + name + "'."); } continue; // already exists. } if (!MasterAudio.CreateBus(aBus.busName, errorOnDuplicates, true)) { continue; } var createdBus = MasterAudio.GrabBusByName(aBus.busName); if (createdBus == null) { continue; } var busVol = PersistentAudioSettings.GetBusVolume(aBus.busName); if (!busVol.HasValue) { createdBus.volume = aBus.volume; createdBus.OriginalVolume = createdBus.volume; } createdBus.voiceLimit = aBus.voiceLimit; createdBus.stopOldest = aBus.stopOldest; createdBus.forceTo2D = aBus.forceTo2D; createdBus.mixerChannel = aBus.mixerChannel; createdBus.busColor = aBus.busColor; createdBus.isUsingOcclusion = aBus.isUsingOcclusion; } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _groupsToCreate.Count; i++) { var aGroup = _groupsToCreate[i]; var busName = string.Empty; var selectedBusIndex = aGroup.busIndex == -1 ? 0 : aGroup.busIndex; if (selectedBusIndex >= HardCodedBusOptions) { var selectedBus = groupBuses[selectedBusIndex - HardCodedBusOptions]; busName = selectedBus.busName; } aGroup.busName = busName; var groupTrans = MasterAudio.CreateSoundGroup(aGroup, _trans.name, errorOnDuplicates); // remove fx components // ReSharper disable ForCanBeConvertedToForeach for (var v = 0; v < aGroup.groupVariations.Count; v++) { // ReSharper restore ForCanBeConvertedToForeach var aVar = aGroup.groupVariations[v]; if (aVar.LowPassFilter != null) { Destroy(aVar.LowPassFilter); } if (aVar.HighPassFilter != null) { Destroy(aVar.HighPassFilter); } if (aVar.DistortionFilter != null) { Destroy(aVar.DistortionFilter); } if (aVar.ChorusFilter != null) { Destroy(aVar.ChorusFilter); } if (aVar.EchoFilter != null) { Destroy(aVar.EchoFilter); } if (aVar.ReverbFilter != null) { Destroy(aVar.ReverbFilter); } } if (groupTrans == null) { continue; } _groupsToRemove.Add(groupTrans); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < musicDuckingSounds.Count; i++) { var aDuck = musicDuckingSounds[i]; if (aDuck.soundType == MasterAudio.NoGroupName) { continue; } MasterAudio.AddSoundGroupToDuckList(aDuck.soundType, aDuck.riseVolStart, aDuck.duckedVolumeCut, aDuck.unduckTime, true); } for (var i = 0; i < customEventCategories.Count; i++) { var aCat = customEventCategories[i]; MasterAudio.CreateCustomEventCategoryIfNotThere(aCat.CatName, true); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < customEventsToCreate.Count; i++) { var anEvent = customEventsToCreate[i]; MasterAudio.CreateCustomEvent(anEvent.EventName, anEvent.eventReceiveMode, anEvent.distanceThreshold, anEvent.eventRcvFilterMode, anEvent.filterModeQty, anEvent.categoryName, true, errorOnDuplicates); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < musicPlaylists.Count; i++) { var aPlaylist = musicPlaylists[i]; aPlaylist.isTemporary = true; MasterAudio.CreatePlaylist(aPlaylist, errorOnDuplicates); } MasterAudio.SilenceOrUnsilenceGroupsFromSoloChange(); // to make sure non-soloed things get muted _hasCreated = true; if (itemsCreatedEventExpanded) { FireEvents(); } }
public override void OnEnter() { MasterAudio.AddSoundGroupToDuckList(soundGroupName.Value, beginUnduck.Value); Finish(); }