private void Update() { if (!_isInitialised) { _groupComponents = FabricManager.Instance.gameObject.GetComponentsInChildren <GroupComponent>(); _isInitialised = true; } if (_presetList != null) { for (int i = 0; i < _presetList.Length; i++) { Preset preset = _presetList[i]; if (preset.HasEventNameSet() && preset.IsEventActive()) { AddPreset(preset); } } } if (_groupComponents == null) { return; } for (int j = 0; j < _groupComponents.Length; j++) { GroupComponent groupComponent = _groupComponents[j]; float num = 0f; float num2 = 1f; for (int k = 0; k < _activePresets.Count; k++) { Preset preset2 = _activePresets[k]; if (preset2.HasEventNameSet() && !preset2.IsEventActive() && !preset2.IsDeactivating) { preset2.Deactivate(); } if (preset2.IsActive()) { GroupPreset groupComponentByID = preset2.GetGroupComponentByID(groupComponent.GetInstanceID()); if (groupComponentByID != null) { num += groupComponentByID.CalculateVolume(); num2 *= groupComponentByID.CalculatePitch(); } } else { _activePresets.Remove(preset2); } } float value = AudioTools.DBToLinear(num); AudioTools.Limit(ref value, 0f, 1f); groupComponent.MixerVolume = value; groupComponent.MixerPitch = num2; } }
public GroupPreset GetGroupComponentByName(string Name) { for (int i = 0; i < _groupPreset.Length; i++) { GroupPreset groupPreset = _groupPreset[i]; if (groupPreset.GroupComponent != null && Name == groupPreset.Name) { return(groupPreset); } } return(null); }
public GroupPreset GetGroupComponentByNameSlow(string Name) { _groupPreset = GetComponents <GroupPreset>(); for (int i = 0; i < _groupPreset.Length; i++) { GroupPreset groupPreset = _groupPreset[i]; if ((bool)groupPreset.GroupComponent && groupPreset.GroupComponent.name == Name) { return(groupPreset); } } return(null); }
public void SwitchFromPreset(Preset sourcePreset) { if (_groupPreset == null) { return; } for (int i = 0; i < sourcePreset._groupPreset.Length; i++) { GroupPreset groupComponentByID = GetGroupComponentByID(sourcePreset._groupPreset[i].GroupComponent.GetInstanceID()); if (groupComponentByID != null) { groupComponentByID.SwitchFromPreset(sourcePreset._groupPreset[i]); } } sourcePreset.Reset(); }
public void SwitchFromPreset(GroupPreset sourcePreset) { _volumeParameter.Reset(sourcePreset._volume); _pitchParameter.Reset(sourcePreset._pitch); Activate(); }
public void AddGroupComponent(GroupComponent groupComponent) { GroupPreset groupPreset = base.gameObject.AddComponent <GroupPreset>(); groupPreset.Init(groupComponent); }