public AudioSource play3DClip(string name, GameObject go, float volume, bool cumulateSources, AudioSource prefab, bool loop = false, AudioMixerGroup audioGroup = null) { if (!cumulateSources) return play3DClip(name, go, volume, loop, audioGroup); AudioClip current = getClip(name); if (current == null) return null; AudioSource[] sources = go.GetComponents<AudioSource>(); foreach (AudioSource a in sources) { if (!a.isPlaying) { set3DSource(a, current, audioGroup, volume, loop); a.Play(); return a; } } AudioSource newSource = null; newSource = go.AddComponent<AudioSource>(); if (prefab != null) newSource = copyAudioSource(newSource, prefab); set3DSource(newSource, current, audioGroup, volume, loop); newSource.Play(); return newSource; }
// Use this for initialization void Start () { first = mixer.FindMatchingGroups("First")[0]; second = mixer.FindMatchingGroups("Second")[0]; mixer.SetFloat("FirstVolume", firstVol); mixer.SetFloat("SecondVolume", secondVol); }
public virtual void LaunchSound(AudioClip sound, AudioMixerGroup mixerGroup) { if(soundManager == null) { setupSoundManager(); } soundManager.PlaySound(sound, mixerGroup); }
public virtual void LaunchMusic(AudioClip Music, AudioMixerGroup mixerGroup) { if (musicManager == null) { setupMusicManager(); } musicManager.PlayMusic(Music, mixerGroup, loop); }
/** * <summary>Sets the volume of an Audio Mixer Group (Unity 5 only).</summary> * <param name = "audioMixerGroup">The Audio Mixer Group to affect</param> * <param name = "parameter">The name of the attenuation parameter</param> * <param name = "volume">The new volume (ranges from 0 to 1)</param> */ public static void SetMixerVolume(AudioMixerGroup audioMixerGroup, string parameter, float volume) { if (audioMixerGroup != null && KickStarter.settingsManager.volumeControl == VolumeControl.AudioMixerGroups) { float attenuation = ((2f * volume) - (volume * volume) - 1f) * 80f; audioMixerGroup.audioMixer.SetFloat (parameter, attenuation); } }
public AudioParameters(float volume, float pitch = 1.0f, float stereoPan = 0.0f, float spatialBlend = 1.0f, AudioMixerGroup mixer = null) { this.volume = Mathf.Clamp01(volume); this.pitch = Mathf.Clamp(pitch, 0f, 3f); this.stereoPan = Mathf.Clamp(stereoPan, -1f, 1f); this.spatialBlend = Mathf.Clamp01(spatialBlend); this.audioMixer = mixer; setMixer = true; }
public AudioSource play3DClip(string name, GameObject go, float volume, bool loop = false, AudioMixerGroup audioGroup = null) { AudioClip current = getClip(name); if (current == null) return null; AudioSource source = go.GetComponent<AudioSource>(); if (source == null) source = go.AddComponent<AudioSource>(); set3DSource(source, current, audioGroup, volume, loop); source.Play(); return source; }
//Step Two: Created a function to play the sound effect... //First created a public function that will play the sound. Set it up to be passed an AudioClip as an argument (arbitrarily named the variable "soundEffect"). Later added a float used to set the pitch (for variety) and an Audio Mixer Group so I could assign different sund effects to different mixer groups. public void PlaySound(AudioClip soundEffect, float pitch, AudioMixerGroup mixer) { soundGenerator = Instantiate (prefab); //Assigned the "soundGenerator" variable to an instance of "prefab" using Unity's "Instantiate()" function. soundGenerator.tag = "SoundEffect"; //Part of my workaroud (see below) source = soundGenerator.GetComponent<AudioSource> (); //Assigned the "source" variable with the audio source component from the instantiated object (NOT the original prefab) using GetComponent. source.outputAudioMixerGroup = mixer; //Assigns the mixer that was passed into the function to the audio source. source.clip = soundEffect; //Set the active clip of the audio source to "soundEffect" source.pitch = pitch; //Sets the pitch of the sound effect (for variety) source.Play (); //Instructed the audio source to play //Step Three: Destroyed the prefab... Destroy (soundGenerator, soundEffect.length); //Called Unity's "Destroy()" function. Passed the instance of prefab and the length of the audio clip (using "soundEffect.length") as arguments. }
public void PlayMusic(AudioClip music, AudioMixerGroup mixer) { soundGenerator = Instantiate (prefab); //Assigned the "soundGenerator" variable to an instance of "prefab" using Unity's "Instantiate()" function. soundGenerator.tag = "Music"; //Part of my workaroud (see below) source = soundGenerator.GetComponent<AudioSource> (); //Assigned the "source" variable with the audio source component from the instantiated object (NOT the original prefab) using GetComponent. source.outputAudioMixerGroup = mixer; //Assigns the mixer that was passed into the function to the audio source. source.clip = music; //Set the active clip of the audio source to "soundEffect" source.loop = true; //Allows me to speficy whether or not I want the clip to loop. Added this so I could make the music loop. source.Play (); //Instructed the audio source to play if (source.loop == false) //If it's not looping... Destroy (soundGenerator, music.length); //...destroy it when the clip ends. }
static int set_outputAudioMixerGroup(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.Audio.AudioMixer obj = (UnityEngine.Audio.AudioMixer)o; UnityEngine.Audio.AudioMixerGroup arg0 = (UnityEngine.Audio.AudioMixerGroup)ToLua.CheckObject <UnityEngine.Audio.AudioMixerGroup>(L, 2); obj.outputAudioMixerGroup = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index outputAudioMixerGroup on a nil value")); } }
static int set_outputAudioMixerGroup(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.AudioSource obj = (UnityEngine.AudioSource)o; UnityEngine.Audio.AudioMixerGroup arg0 = (UnityEngine.Audio.AudioMixerGroup)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Audio.AudioMixerGroup)); obj.outputAudioMixerGroup = arg0; return 0; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index outputAudioMixerGroup on a nil value" : e.Message); } }
static int get_outputAudioMixerGroup(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.AudioSource obj = (UnityEngine.AudioSource)o; UnityEngine.Audio.AudioMixerGroup ret = obj.outputAudioMixerGroup; ToLua.Push(L, ret); return 1; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index outputAudioMixerGroup on a nil value" : e.Message); } }
static int get_outputAudioMixerGroup(IntPtr L) { UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.ToObject(L, 1); UnityEngine.Audio.AudioMixerGroup ret = null; try { ret = obj.outputAudioMixerGroup; } catch (Exception e) { return(LuaDLL.luaL_error(L, obj == null ? "attempt to index outputAudioMixerGroup on a nil value" : e.Message)); } ToLua.Push(L, ret); return(1); }
public void PlayMusic(AudioClip music, AudioMixerGroup mixerGroup, bool looping) { audioSource.Stop(); audioSource.clip = music; audioSource.outputAudioMixerGroup = mixerGroup; audioSource.loop = looping; audioSource.Play(); if(!looping) { Invoke("PlayLastLoopingMusic", music.length); } else { lastLoopingMusic = music; lastLoopingMusicMixerGroup = mixerGroup; } }
public void ChangePitch(float ratio) { float pitch; if (Application.platform == RuntimePlatform.WebGLPlayer) { pitch = source.pitch; pitch += pitch * ratio; source.pitch = pitch; } else { UnityEngine.Audio.AudioMixerGroup mixer = source.outputAudioMixerGroup; mixer.audioMixer.GetFloat("PitchVolume", out pitch); pitch += pitch * ratio; mixer.audioMixer.SetFloat("PitchVolume", pitch); } }
public AudioSource PlayClip(int seed, Vector3 pos, UnityEngine.Audio.AudioMixerGroup defaultGroup = null, float addedDelay = 0) { if (!CanPlay) { return(null); } var clip = Clip(seed); if (clip == null) { return(null); } var checkRepeteation = CheckRepeteation; var time = Time.time; var realDelay = addedDelay + _delay; var startTime = time + realDelay; var id = 0; if (checkRepeteation) { CleanOtherPlays(); id = MyID(realDelay); if (!PlayIsValid(id, realDelay)) { return(null); } } var source = Guaranteed <AudioManager> .Instance.PlayOnce(clip, pos, _config, defaultGroup, realDelay); if (checkRepeteation) { CreateRepetitionRegistry(id, source, startTime); } return(source); }
public void initMusicControl(AudioMixerGroup[] mixer_groups) { float master_vol, music_vol, sounds_vol; foreach (AudioMixerGroup g in mixer_groups) { if (g.name.Equals("Master")) master_mixer = g; else if (g.name.Equals("Music")) music_mixer = g; else if (g.name.Equals("Sounds")) sounds_mixer = g; } master_mixer.audioMixer.GetFloat("MasterVol", out master_vol); music_mixer.audioMixer.GetFloat("MusicVol", out music_vol); sounds_mixer.audioMixer.GetFloat("SoundsVol", out sounds_vol); master_slider.value = Mathf.Pow(10, (master_vol / 20f)); // Db to [0, 1] music_slider.value = Mathf.Pow(10, (music_vol / 20f)); sounds_slider.value = Mathf.Pow(10, (sounds_vol / 20f)); }
public AudioChannel Play(AudioAsset audioAsset , bool loop = false , AudioMixerGroup audioMixerGroup = null) { if (audioAsset == null) { return null; } foreach (AudioChannel channel in channels) { if (claimedChannels.Contains(channel)) { continue; } if (channel.Play(audioAsset , loop , audioMixerGroup)) { return channel; } } Debug.LogWarning("[AudioManager] No available audio channels for audio asset: " + audioAsset); return null; }
//void LateUpdate() //{ // foreach (var audioClip in audioClipsQueue) // { // Play(audioClip, 1, 1, 1, 1); // } // audioClipsQueue.Clear(); //} //public void AddAudioClipToQueue(AudioClip clip, float minVol, float maxVol) //{ // if (!audioClipsQueue.Contains(clip)) // { // audioClipsQueue.Add(clip); // } //} public void Play(AudioClip clip, AudioMixerGroup group, float minVol = 1.0f, float maxVol = 1.0f, float minPitch = 1.0f, float maxPitch = 1.0f) { AudioSource audioSource = Instantiate(AudioSourcePrefab, transform.position, transform.rotation) as AudioSource; audioSource.transform.parent = this.transform; // TODO: add audiomixergroup to audiosource... if (minPitch != 1.0f || maxPitch != 1.0f) { audioSource.pitch = Random.Range(minPitch, maxPitch); } if (minVol != 1.0f || maxVol != 1.0f) { audioSource.volume = Random.Range(minVol, maxVol); } AudioSourceExtended audioSourceExtended = audioSource.GetComponent<AudioSourceExtended>(); audioSourceExtended.Duration = clip.length; audioSource.clip = clip; audioSource.outputAudioMixerGroup = group; audioSource.Play(); }
public static void PlaySound(AudioClip _clip, GameObject _parent , float _volume = 0.5f, float blend = 1f, bool isLoop = false, UnityEngine.Audio.AudioMixerGroup _group = null) { if (_clip == null) { return; } AudioSource source = _parent.AddComponent <AudioSource> (); source.clip = _clip; source.volume = _volume; source.spatialBlend = blend; source.loop = isLoop; source.Play(); GameObject.Destroy(source, _clip.length + 1f); }
internal void SetMixerGroup(AudioMixerGroup mixerGroup) { twoSources[0].outputAudioMixerGroup = mixerGroup; twoSources[1].outputAudioMixerGroup = mixerGroup; }
internal extern float GetAbsoluteAudibilityFromGroup(AudioMixerGroup group);
public override void OnInspectorGUI() { if (source == null) { return; } #region ClipType handler ClipType clipType = script.clipType; clipType = (ClipType)EditorGUILayout.EnumPopup("Clip Type", clipType); if (clipType != script.clipType) { SoundManagerEditorTools.RegisterObjectChange("Change Clip Type", script); script.clipType = clipType; if (script.clipType != ClipType.AudioClip) { source.clip = null; } EditorUtility.SetDirty(script); } switch (script.clipType) { case ClipType.ClipFromSoundManager: string clipName = script.clipName; clipName = EditorGUILayout.TextField("Audio Clip Name", clipName); if (clipName != script.clipName) { SoundManagerEditorTools.RegisterObjectChange("Change Clip Name", script); script.clipName = clipName; EditorUtility.SetDirty(script); } break; case ClipType.ClipFromGroup: string groupName = script.groupName; groupName = EditorGUILayout.TextField("SFXGroup Name", groupName); if (groupName != script.groupName) { SoundManagerEditorTools.RegisterObjectChange("Change SFXGroup Name", script); script.groupName = groupName; EditorUtility.SetDirty(script); } break; case ClipType.AudioClip: default: AudioClip clip = source.clip; clip = EditorGUILayout.ObjectField("Audio Clip", clip, typeof(AudioClip), false) as AudioClip; if (clip != source.clip) { SoundManagerEditorTools.RegisterObjectChange("Change Audio Clip", script); source.clip = clip; EditorUtility.SetDirty(script); } break; } #endregion #region audio source settings EditorGUILayout.Space(); UnityEngine.Audio.AudioMixerGroup outputAudioMixerGroup = source.outputAudioMixerGroup; outputAudioMixerGroup = EditorGUILayout.ObjectField("Output", outputAudioMixerGroup, typeof(UnityEngine.Audio.AudioMixerGroup), false) as UnityEngine.Audio.AudioMixerGroup; if (outputAudioMixerGroup != source.outputAudioMixerGroup) { SoundManagerEditorTools.RegisterObjectChange("Change Output AudioMixerGroup", script); source.outputAudioMixerGroup = outputAudioMixerGroup; EditorUtility.SetDirty(script); } source.mute = EditorGUILayout.Toggle("Mute", source.mute); source.bypassEffects = EditorGUILayout.Toggle("Bypass Effects", source.bypassEffects); source.bypassListenerEffects = EditorGUILayout.Toggle("Bypass Listener Effects", source.bypassListenerEffects); source.bypassReverbZones = EditorGUILayout.Toggle("Bypass Reverb Zones", source.bypassReverbZones); source.playOnAwake = EditorGUILayout.Toggle("Play On Awake", source.playOnAwake); source.loop = EditorGUILayout.Toggle("Loop", source.loop); EditorGUILayout.Space(); source.priority = EditorGUILayout.IntSlider("Priority", source.priority, 0, 256); EditorGUILayout.Space(); source.volume = EditorGUILayout.Slider("Volume", source.volume, 0f, 1f); EditorGUILayout.Space(); source.pitch = EditorGUILayout.Slider("Pitch", source.pitch, -3f, 3f); EditorGUILayout.Space(); source.panStereo = EditorGUILayout.Slider("Stereo Pan", source.panStereo, -1f, 1f); EditorGUILayout.Space(); source.spatialBlend = EditorGUILayout.Slider("Spatial Blend", source.spatialBlend, 0f, 1f); EditorGUILayout.Space(); source.reverbZoneMix = EditorGUILayout.Slider("Reverb Zone Mix", source.reverbZoneMix, 0f, 1.1f); EditorGUILayout.Space(); script.ShowEditor3D = EditorGUILayout.Foldout(script.ShowEditor3D, "3D Sound Settings"); if (script.ShowEditor3D) { EditorGUI.indentLevel++; { source.dopplerLevel = EditorGUILayout.Slider("Doppler Level", source.dopplerLevel, 0f, 5f); EditorGUILayout.Space(); AudioRolloffMode mode = source.rolloffMode; mode = (AudioRolloffMode)EditorGUILayout.EnumPopup("Volume Rolloff", mode); if (mode != AudioRolloffMode.Custom) { source.rolloffMode = mode; if (GUI.changed && notAvailable) { notAvailable = false; } } else { notAvailable = true; } if (notAvailable) { GUI.color = Color.red; EditorGUI.indentLevel += 2; { EditorGUILayout.LabelField("Custom Volume Rolloff not available", EditorStyles.whiteLabel); } EditorGUI.indentLevel -= 2; GUI.color = Color.white; } EditorGUI.indentLevel++; { float minD = source.minDistance; minD = EditorGUILayout.FloatField("Min Distance", minD); if (minD < 0f) { minD = 0f; } source.minDistance = minD; } EditorGUI.indentLevel--; source.spread = EditorGUILayout.Slider("Spread", source.spread, 0f, 360f); float maxD = source.maxDistance; maxD = EditorGUILayout.FloatField("Max Distance", maxD); if (maxD < source.minDistance + 3f) { maxD = source.minDistance + 3f; } source.maxDistance = maxD; if (GUI.changed) { CalculateCurve(); } GUI.enabled = false; EditorGUILayout.BeginHorizontal(); { curve = EditorGUILayout.CurveField(curve, Color.red, new Rect(0f, 0f, source.maxDistance, 1f), GUILayout.Height(100f), GUILayout.ExpandWidth(false)); spatialCurve = EditorGUILayout.CurveField(spatialCurve, Color.green, new Rect(0f, 0f, source.maxDistance, 1f), GUILayout.Height(100f), GUILayout.ExpandWidth(false)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUI.color = Color.red; EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false)); GUI.color = Color.white; GUI.enabled = true; GUILayout.Label("Volume"); GUI.enabled = false; GUI.color = Color.green; EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false)); GUI.color = Color.white; GUI.enabled = true; GUILayout.Label("Spatial"); GUI.enabled = false; GUI.color = Color.white; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { spreadCurve = EditorGUILayout.CurveField(spreadCurve, Color.blue, new Rect(0f, 0f, source.maxDistance, 360f), GUILayout.Height(100f), GUILayout.ExpandWidth(false)); reverbCurve = EditorGUILayout.CurveField(reverbCurve, Color.yellow, new Rect(0f, 0f, source.maxDistance, 1.1f), GUILayout.Height(100f), GUILayout.ExpandWidth(false)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUI.color = Color.blue; EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false)); GUI.color = Color.white; GUI.enabled = true; GUILayout.Label("Spread"); GUI.enabled = false; GUI.color = Color.yellow; EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false)); GUI.color = Color.white; GUI.enabled = true; GUILayout.Label("Reverb"); GUI.enabled = false; GUI.color = Color.white; } EditorGUILayout.EndHorizontal(); GUI.enabled = true; } EditorGUI.indentLevel--; } #endregion #region events EditorGUILayout.Space(); script.ShowEventTriggers = EditorGUILayout.Foldout(script.ShowEventTriggers, "Event Trigger Settings"); if (script.ShowEventTriggers) { for (int i = 0; i < script.numSubscriptions; i++) { EditorGUI.indentLevel++; { EditorGUILayout.BeginVertical(EditorStyles.objectFieldThumb, GUILayout.ExpandWidth(true)); { if (script.audioSubscriptions[i].sourceComponent == null) { EditorGUILayout.HelpBox("Drag a Component from THIS GameObject Below (Optional)", MessageType.None); } EditorGUILayout.BeginHorizontal(); var sourceComponent = ComponentField("Component", script.audioSubscriptions[i].sourceComponent); if (GUILayout.Button("Clear")) { sourceComponent = null; } GUI.color = Color.red; if (GUILayout.Button("Remove")) { RemoveEvent(i); return; } GUI.color = Color.white; if (sourceComponent != script.audioSubscriptions[i].sourceComponent) { SoundManagerEditorTools.RegisterObjectChange("Change Event Component", script); script.audioSubscriptions[i].sourceComponent = sourceComponent; EditorUtility.SetDirty(script); } EditorGUILayout.EndHorizontal(); int skippedStandardEvents = 0; List <string> sourceComponentMembers = new List <string>(); if (sourceComponent != null) { sourceComponentMembers = sourceComponent.GetType() .GetEvents(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Where(f => f.EventHandlerType.GetMethod("Invoke").GetParameters().Length == 0 && f.EventHandlerType.GetMethod("Invoke").ReturnType == typeof(void) && !IsAlreadyBound(f.Name, i)) .Select(m => m.Name).ToList(); } AudioSourceStandardEvent[] standardEvents = Enum.GetValues(typeof(AudioSourceStandardEvent)).Cast <AudioSourceStandardEvent>().ToArray(); foreach (AudioSourceStandardEvent standardEvent in standardEvents) { if (!IsAlreadyBound(standardEvent.ToString(), i)) { sourceComponentMembers.Add(standardEvent.ToString()); } else { skippedStandardEvents++; } } sourceComponentMembers.Add(nullEvent); int numStandardEvents = standardEvents.Length - skippedStandardEvents; string[] sourceComponentMembersArray = sourceComponentMembers.ToArray(); var memberIndex = findIndex(sourceComponentMembersArray, script.audioSubscriptions[i].methodName); if (memberIndex == -1) { memberIndex = sourceComponentMembers.Count - 1; script.audioSubscriptions[i].methodName = ""; } var selectedIndex = EditorGUILayout.Popup("Compatible Events", memberIndex, sourceComponentMembersArray); if (selectedIndex >= 0 && selectedIndex < sourceComponentMembersArray.Length) { var memberName = sourceComponentMembersArray[selectedIndex]; if (memberName != script.audioSubscriptions[i].methodName) { SoundManagerEditorTools.RegisterObjectChange("Change Event", script); script.audioSubscriptions[i].methodName = memberName; EditorUtility.SetDirty(script); } } if (selectedIndex == sourceComponentMembersArray.Length - 1) { EditorGUILayout.HelpBox("No event configuration selected.", MessageType.None); } else if (selectedIndex < sourceComponentMembersArray.Length - numStandardEvents - 1 && !script.audioSubscriptions[i].componentIsValid) { #if !(UNITY_WP8 || UNITY_METRO) EditorGUILayout.HelpBox("Configuration is invalid.", MessageType.Error); #else EditorGUILayout.HelpBox("Configuration is invalid. Keep in mind that custom event configurations are not supported in the Win8Phone and WinStore platforms.", MessageType.Error); #endif } else { if (selectedIndex + numStandardEvents < sourceComponentMembersArray.Length - 1) { if (script.audioSubscriptions[i].isStandardEvent) { script.BindStandardEvent(script.audioSubscriptions[i].standardEvent, false); } script.audioSubscriptions[i].isStandardEvent = false; } else { script.audioSubscriptions[i].isStandardEvent = true; script.audioSubscriptions[i].standardEvent = (AudioSourceStandardEvent)Enum.Parse(typeof(AudioSourceStandardEvent), sourceComponentMembersArray[selectedIndex]); script.BindStandardEvent(script.audioSubscriptions[i].standardEvent, true); if (IsColliderEvent(script.audioSubscriptions[i].standardEvent)) { EditorGUI.indentLevel += 2; { //tags EditorGUILayout.BeginHorizontal(); bool filterTags = script.audioSubscriptions[i].filterTags; filterTags = EditorGUILayout.Toggle(filterTags, GUILayout.Width(40f)); if (filterTags != script.audioSubscriptions[i].filterTags) { SoundManagerEditorTools.RegisterObjectChange("Filter Tags", script); script.audioSubscriptions[i].filterTags = filterTags; EditorUtility.SetDirty(script); } EditorGUILayout.LabelField("Filter Tags:", GUILayout.Width(110f)); GUI.enabled = filterTags; int tagMask = script.audioSubscriptions[i].tagMask; tagMask = EditorGUILayout.MaskField(tagMask, UnityEditorInternal.InternalEditorUtility.tags, GUILayout.ExpandWidth(true)); if (tagMask != script.audioSubscriptions[i].tagMask) { SoundManagerEditorTools.RegisterObjectChange("Change Tag Filter", script); script.audioSubscriptions[i].tagMask = tagMask; script.audioSubscriptions[i].tags.Clear(); for (int t = 0; t < UnityEditorInternal.InternalEditorUtility.tags.Length; t++) { if ((tagMask & 1 << t) != 0) { script.audioSubscriptions[i].tags.Add(UnityEditorInternal.InternalEditorUtility.tags[t]); } } EditorUtility.SetDirty(script); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); //layers EditorGUILayout.BeginHorizontal(); bool filterLayers = script.audioSubscriptions[i].filterLayers; filterLayers = EditorGUILayout.Toggle(filterLayers, GUILayout.Width(40f)); if (filterLayers != script.audioSubscriptions[i].filterLayers) { SoundManagerEditorTools.RegisterObjectChange("Filter Layers", script); script.audioSubscriptions[i].filterLayers = filterLayers; EditorUtility.SetDirty(script); } EditorGUILayout.LabelField("Filter Layers:", GUILayout.Width(110f)); GUI.enabled = filterLayers; int layerMask = script.audioSubscriptions[i].layerMask; layerMask = EditorGUILayout.LayerField(layerMask, GUILayout.ExpandWidth(true)); if (layerMask != script.audioSubscriptions[i].layerMask) { SoundManagerEditorTools.RegisterObjectChange("Change Layer Filter", script); script.audioSubscriptions[i].layerMask = layerMask; EditorUtility.SetDirty(script); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); //names EditorGUILayout.BeginHorizontal(); bool filterNames = script.audioSubscriptions[i].filterNames; filterNames = EditorGUILayout.Toggle(filterNames, GUILayout.Width(40f)); if (filterNames != script.audioSubscriptions[i].filterNames) { SoundManagerEditorTools.RegisterObjectChange("Filter Names", script); script.audioSubscriptions[i].filterNames = filterNames; EditorUtility.SetDirty(script); } EditorGUILayout.LabelField("Filter Names:", GUILayout.Width(110f)); GUI.enabled = filterNames; int nameMask = script.audioSubscriptions[i].nameMask; nameMask = EditorGUILayout.MaskField(nameMask, script.audioSubscriptions[i].allNames.ToArray(), GUILayout.ExpandWidth(true)); if (nameMask != script.audioSubscriptions[i].nameMask) { SoundManagerEditorTools.RegisterObjectChange("Change Name Filter", script); script.audioSubscriptions[i].nameMask = nameMask; script.audioSubscriptions[i].names.Clear(); for (int n = 0; n < script.audioSubscriptions[i].allNames.Count; n++) { if ((nameMask & 1 << n) != 0) { script.audioSubscriptions[i].names.Add(script.audioSubscriptions[i].allNames[n]); } } EditorUtility.SetDirty(script); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (filterNames) { EditorGUI.indentLevel += 2; { EditorGUILayout.BeginHorizontal(); script.audioSubscriptions[i].nameToAdd = EditorGUILayout.TextField(script.audioSubscriptions[i].nameToAdd); if (GUILayout.Button("Add Name")) { if (!string.IsNullOrEmpty(script.audioSubscriptions[i].nameToAdd) && !script.audioSubscriptions[i].names.Contains(script.audioSubscriptions[i].nameToAdd)) { SoundManagerEditorTools.RegisterObjectChange("Add Name Filter", script); script.audioSubscriptions[i].allNames.Add(script.audioSubscriptions[i].nameToAdd); script.audioSubscriptions[i].nameToAdd = ""; GUIUtility.keyboardControl = 0; EditorUtility.SetDirty(script); } } if (GUILayout.Button("Clear Names")) { SoundManagerEditorTools.RegisterObjectChange("Clear Name Filter", script); script.audioSubscriptions[i].allNames.Clear(); script.audioSubscriptions[i].names.Clear(); EditorUtility.SetDirty(script); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel -= 2; } } EditorGUI.indentLevel -= 2; } } if (sourceComponent != null && sourceComponentMembersArray.Length - numStandardEvents == 1) { EditorGUILayout.HelpBox("There are no compatible custom events on this Component. Only void parameterless events are allowed.", MessageType.None); } AudioSourceAction actionType = script.audioSubscriptions[i].actionType; actionType = (AudioSourceAction)EditorGUILayout.EnumPopup("AudioSource Action", actionType); if (actionType != script.audioSubscriptions[i].actionType) { SoundManagerEditorTools.RegisterObjectChange("Change AudioSource Action", script); script.audioSubscriptions[i].actionType = actionType; EditorUtility.SetDirty(script); } if (actionType == AudioSourceAction.PlayCapped) { string cappedName = script.audioSubscriptions[i].cappedName; cappedName = EditorGUILayout.TextField("Cap ID", cappedName); if (cappedName != script.audioSubscriptions[i].cappedName) { SoundManagerEditorTools.RegisterObjectChange("Change Cap ID", script); script.audioSubscriptions[i].cappedName = cappedName; EditorUtility.SetDirty(script); } } } } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; } EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Event Trigger")) { AddEvent(); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); } #endregion }
//Transfers audio settings from an AudioSource. Only used in the editor public void TransferFromAudioSource(AudioSource source) { Loop = source.loop; Volume = source.volume; AudioClip = source.clip; BypassEffects = source.bypassEffects; BypassListenerEffects = source.bypassListenerEffects; BypassReverbZones = source.bypassReverbZones; DopplerLevel = source.dopplerLevel; MaxDistance = source.maxDistance; MinDistance = source.minDistance; Mute = source.mute; OutputAudioMixerGroup = source.outputAudioMixerGroup; PanStereo = source.panStereo; Pitch = source.pitch; Priority = source.priority; RolloffMode = source.rolloffMode; SpatialBlend = source.spatialBlend; ReverbZoneMix = source.reverbZoneMix; Spatialize = source.spatialize; if(RolloffMode == AudioRolloffMode.Custom) { CustomRolloffCurve = source.GetCustomCurve(AudioSourceCurveType.CustomRolloff); } else { CustomRolloffCurve = null; } }
void set3DSource(AudioSource source, AudioClip clip, AudioMixerGroup audioGroup, float volume, bool loop) { if (source == null) return; source.clip = clip; if (audioGroup != null) source.outputAudioMixerGroup = audioGroup; else source.outputAudioMixerGroup = _master; source.volume = volume; source.spatialBlend = 1f; source.loop = loop; }
public void RouteToMixerChannel(AudioMixerGroup group) { _activeAudio.outputAudioMixerGroup = group; _transitioningAudio.outputAudioMixerGroup = group; }
public void RouteBusToUnityMixerGroup(string busName, AudioMixerGroup mixerGroup) { var busIndex = GetBusIndex(busName, true); if (busIndex < 0) { return; } var sources = AudioSourcesBySoundType.GetEnumerator(); // ReSharper disable TooWideLocalVariableScope MasterAudioGroup aGroup; AudioGroupInfo aInfo; // ReSharper restore TooWideLocalVariableScope while (sources.MoveNext()) { aInfo = sources.Current.Value; aGroup = aInfo.Group; if (aGroup.busIndex != busIndex) { continue; } RouteGroupToUnityMixerGroup(aGroup.name, mixerGroup); } }
public virtual AudioSource PlaySomeClip(Transform parent, UnityEngine.Audio.AudioMixerGroup defaultGroup = null, float addedDelay = 0) { return(PlayClip(RandomId, parent, defaultGroup, addedDelay + _delay)); }
GameObject CreateNewSource(AudioClip clip, Transform parent, AudioSourceConfiguration config, UnityEngine.Audio.AudioMixerGroup defaultGroup = null) { var go = new GameObject(clip.name); go.transform.parent = parent; var source = go.AddComponent <AudioSource>(); source.clip = clip; config.SetConfiguration(source); if (source.outputAudioMixerGroup == null) { source.outputAudioMixerGroup = defaultGroup ?? _defaultGroup; } return(go); }
public ILoopSFX PlayLoop(AudioClip loopClip, Transform anchor, AudioSourceConfiguration config, UnityEngine.Audio.AudioMixerGroup defaultGroup = null) { if (loopClip == null) { Debug.LogError("Cannot play sound clip, because it is null"); return(null); } var go = CreateNewSource(loopClip, transform, config, defaultGroup); var loop = go.AddComponent <LoopController>(); loop.Init(config, anchor); return(loop); }
static public void FastSetter(this UnityEngine.AudioSource o, string propertyName, UnityEngine.Audio.AudioMixerGroup value) { switch (propertyName) { case "outputAudioMixerGroup": o.outputAudioMixerGroup = value; return; } LBoot.LogUtil.Error("UnityEngine.AudioSource no Setter Found : " + propertyName); }
public AudioSource playClip(string name, float volume, bool loop, AudioMixerGroup audioGroup) { AudioClip current = getClip(name); if (current == null) return null; return playClip(current, volume, loop, audioGroup); }
public AudioSource playClip(AudioClip clip, float volume, bool loop, AudioMixerGroup audioGroup) { AudioSource source = findAvailableAudioSource(); source.clip = clip; if (audioGroup != null) source.outputAudioMixerGroup = audioGroup; source.volume = volume; source.loop = loop; source.Play(); /*#if UNITY_EDITOR GameConsole.instance.writeNewMessage("[" + GetType() + "] " + name + " : play " + clip.name); #endif*/ return source; }
public void SetMixerGroup(AudioMixerGroup mixerGroup) { if(audioMaster != null){ if(audioMaster.audioMixer != null){ AudioSource source = this.GetComponent<AudioSource> (); if(source != null){ source.outputAudioMixerGroup = mixerGroup; } } } }
internal static extern bool CheckForCyclicReferences(AudioMixer mixer, AudioMixerGroup group);
public void ShowGUI() { EditorGUILayout.LabelField ("Save game settings", EditorStyles.boldLabel); if (saveFileName == "") { saveFileName = SaveSystem.SetProjectName (); } maxSaves = EditorGUILayout.IntField ("Max. number of saves:", maxSaves); saveFileName = EditorGUILayout.TextField ("Save filename:", saveFileName); useProfiles = EditorGUILayout.ToggleLeft ("Enable save game profiles?", useProfiles); #if !UNITY_WEBPLAYER && !UNITY_ANDROID && !UNITY_WINRT && !UNITY_WII saveTimeDisplay = (SaveTimeDisplay) EditorGUILayout.EnumPopup ("Time display:", saveTimeDisplay); takeSaveScreenshots = EditorGUILayout.ToggleLeft ("Take screenshot when saving?", takeSaveScreenshots); orderSavesByUpdateTime = EditorGUILayout.ToggleLeft ("Order save lists by update time?", orderSavesByUpdateTime); #else EditorGUILayout.HelpBox ("Save-game screenshots are disabled for WebPlayer, Windows Store and Android platforms.", MessageType.Info); takeSaveScreenshots = false; #endif EditorGUILayout.Space (); EditorGUILayout.LabelField ("Cutscene settings:", EditorStyles.boldLabel); actionListOnStart = ActionListAssetMenu.AssetGUI ("ActionList on start game:", actionListOnStart); blackOutWhenSkipping = EditorGUILayout.Toggle ("Black out when skipping?", blackOutWhenSkipping); EditorGUILayout.Space (); EditorGUILayout.LabelField ("Character settings:", EditorStyles.boldLabel); CreatePlayersGUI (); EditorGUILayout.Space (); EditorGUILayout.LabelField ("Interface settings", EditorStyles.boldLabel); movementMethod = (MovementMethod) EditorGUILayout.EnumPopup ("Movement method:", movementMethod); if (movementMethod == MovementMethod.UltimateFPS && !UltimateFPSIntegration.IsDefinePresent ()) { EditorGUILayout.HelpBox ("The 'UltimateFPSIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning); } inputMethod = (InputMethod) EditorGUILayout.EnumPopup ("Input method:", inputMethod); interactionMethod = (AC_InteractionMethod) EditorGUILayout.EnumPopup ("Interaction method:", interactionMethod); if (inputMethod != InputMethod.TouchScreen) { useOuya = EditorGUILayout.ToggleLeft ("Playing on OUYA platform?", useOuya); if (useOuya && !OuyaIntegration.IsDefinePresent ()) { EditorGUILayout.HelpBox ("The 'OUYAIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning); } if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction) { selectInteractions = (SelectInteractions) EditorGUILayout.EnumPopup ("Select Interactions by:", selectInteractions); if (selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot) { seeInteractions = (SeeInteractions) EditorGUILayout.EnumPopup ("See Interactions with:", seeInteractions); if (seeInteractions == SeeInteractions.ClickOnHotspot) { stopPlayerOnClickHotspot = EditorGUILayout.ToggleLeft ("Stop player moving when click Hotspot?", stopPlayerOnClickHotspot); } } if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot) { autoCycleWhenInteract = EditorGUILayout.ToggleLeft ("Auto-cycle after an Interaction?", autoCycleWhenInteract); } if (SelectInteractionMethod () == SelectInteractions.ClickingMenu) { clickUpInteractions = EditorGUILayout.ToggleLeft ("Trigger interaction by releasing click?", clickUpInteractions); cancelInteractions = (CancelInteractions) EditorGUILayout.EnumPopup ("Close interactions with:", cancelInteractions); } else { cancelInteractions = CancelInteractions.CursorLeavesMenu; } } } if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot) { autoCycleWhenInteract = EditorGUILayout.ToggleLeft ("Reset cursor after an Interaction?", autoCycleWhenInteract); } if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen) { // First person dragging only works if cursor is unlocked lockCursorOnStart = false; } else { lockCursorOnStart = EditorGUILayout.ToggleLeft ("Lock cursor in screen's centre when game begins?", lockCursorOnStart); hideLockedCursor = EditorGUILayout.ToggleLeft ("Hide cursor when locked in screen's centre?", hideLockedCursor); onlyInteractWhenCursorUnlocked = EditorGUILayout.ToggleLeft ("Disallow Interactions if cursor is locked?", onlyInteractWhenCursorUnlocked); } if (IsInFirstPerson ()) { disableFreeAimWhenDragging = EditorGUILayout.ToggleLeft ("Disable free-aim when dragging?", disableFreeAimWhenDragging); if (movementMethod == MovementMethod.FirstPerson) { useFPCamDuringConversations = EditorGUILayout.ToggleLeft ("Run Conversations in first-person?", useFPCamDuringConversations); } } if (inputMethod != InputMethod.TouchScreen) { runConversationsWithKeys = EditorGUILayout.ToggleLeft ("Dialogue options can be selected with number keys?", runConversationsWithKeys); } EditorGUILayout.Space (); EditorGUILayout.LabelField ("Inventory settings", EditorStyles.boldLabel); if (interactionMethod != AC_InteractionMethod.ContextSensitive) { inventoryInteractions = (InventoryInteractions) EditorGUILayout.EnumPopup ("Inventory interactions:", inventoryInteractions); if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction) { if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot) { cycleInventoryCursors = EditorGUILayout.ToggleLeft ("Include Inventory items in Interaction cycles?", cycleInventoryCursors); } else { cycleInventoryCursors = EditorGUILayout.ToggleLeft ("Include Inventory items in Interaction menus?", cycleInventoryCursors); } } if (inventoryInteractions == InventoryInteractions.Multiple && CanSelectItems (false)) { selectInvWithUnhandled = EditorGUILayout.ToggleLeft ("Select item if Interaction is unhandled?", selectInvWithUnhandled); if (selectInvWithUnhandled) { CursorManager cursorManager = AdvGame.GetReferences ().cursorManager; if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0) { selectInvWithIconID = GetIconID ("Select with unhandled:", selectInvWithIconID, cursorManager); } else { EditorGUILayout.HelpBox ("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info); } } giveInvWithUnhandled = EditorGUILayout.ToggleLeft ("Give item if Interaction is unhandled?", giveInvWithUnhandled); if (giveInvWithUnhandled) { CursorManager cursorManager = AdvGame.GetReferences ().cursorManager; if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0) { giveInvWithIconID = GetIconID ("Give with unhandled:", giveInvWithIconID, cursorManager); } else { EditorGUILayout.HelpBox ("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info); } } } } if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && selectInteractions != SelectInteractions.ClickingMenu && inventoryInteractions == InventoryInteractions.Multiple) {} else { reverseInventoryCombinations = EditorGUILayout.ToggleLeft ("Combine interactions work in reverse?", reverseInventoryCombinations); } //if (interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || inventoryInteractions == InventoryInteractions.Single) if (CanSelectItems (false)) { inventoryDragDrop = EditorGUILayout.ToggleLeft ("Drag and drop Inventory interface?", inventoryDragDrop); if (!inventoryDragDrop) { if (interactionMethod == AC_InteractionMethod.ContextSensitive || inventoryInteractions == InventoryInteractions.Single) { rightClickInventory = (RightClickInventory) EditorGUILayout.EnumPopup ("Right-click active item:", rightClickInventory); } } else if (inventoryInteractions == AC.InventoryInteractions.Single) { inventoryDropLook = EditorGUILayout.ToggleLeft ("Can drop an Item onto itself to Examine it?", inventoryDropLook); } } if (CanSelectItems (false) && !inventoryDragDrop) { inventoryDisableLeft = EditorGUILayout.ToggleLeft ("Left-click deselects active item?", inventoryDisableLeft); if (movementMethod == MovementMethod.PointAndClick && !inventoryDisableLeft) { canMoveWhenActive = EditorGUILayout.ToggleLeft ("Can move player if an Item is active?", canMoveWhenActive); } } inventoryActiveEffect = (InventoryActiveEffect) EditorGUILayout.EnumPopup ("Active cursor FX:", inventoryActiveEffect); if (inventoryActiveEffect == InventoryActiveEffect.Pulse) { inventoryPulseSpeed = EditorGUILayout.Slider ("Active FX pulse speed:", inventoryPulseSpeed, 0.5f, 2f); } activeWhenUnhandled = EditorGUILayout.ToggleLeft ("Show Active FX when an Interaction is unhandled?", activeWhenUnhandled); canReorderItems = EditorGUILayout.ToggleLeft ("Items can be re-ordered in Menu?", canReorderItems); hideSelectedFromMenu = EditorGUILayout.ToggleLeft ("Hide currently active Item in Menu?", hideSelectedFromMenu); activeWhenHover = EditorGUILayout.ToggleLeft ("Show Active FX when Cursor hovers over Item in Menu?", activeWhenHover); EditorGUILayout.Space (); EditorGUILayout.LabelField ("Required inputs:", EditorStyles.boldLabel); EditorGUILayout.HelpBox ("The following inputs are available for the chosen interface settings:" + GetInputList (), MessageType.Info); EditorGUILayout.Space (); EditorGUILayout.LabelField ("Movement settings", EditorStyles.boldLabel); if ((inputMethod == InputMethod.TouchScreen && movementMethod != MovementMethod.PointAndClick) || movementMethod == MovementMethod.Drag) { dragWalkThreshold = EditorGUILayout.FloatField ("Walk threshold:", dragWalkThreshold); dragRunThreshold = EditorGUILayout.FloatField ("Run threshold:", dragRunThreshold); if (inputMethod == InputMethod.TouchScreen && movementMethod == MovementMethod.FirstPerson) { freeAimTouchSpeed = EditorGUILayout.FloatField ("Freelook speed:", freeAimTouchSpeed); } drawDragLine = EditorGUILayout.Toggle ("Draw drag line?", drawDragLine); if (drawDragLine) { dragLineWidth = EditorGUILayout.FloatField ("Drag line width:", dragLineWidth); dragLineColor = EditorGUILayout.ColorField ("Drag line colour:", dragLineColor); } } else if (movementMethod == MovementMethod.Direct) { magnitudeAffectsDirect = EditorGUILayout.ToggleLeft ("Input magnitude affects speed?", magnitudeAffectsDirect); directMovementType = (DirectMovementType) EditorGUILayout.EnumPopup ("Direct-movement type:", directMovementType); if (directMovementType == DirectMovementType.RelativeToCamera) { limitDirectMovement = (LimitDirectMovement) EditorGUILayout.EnumPopup ("Movement limitation:", limitDirectMovement); if (cameraPerspective == CameraPerspective.ThreeD) { directMovementPerspective = EditorGUILayout.ToggleLeft ("Account for player's position on screen?", directMovementPerspective); } } } else if (movementMethod == MovementMethod.PointAndClick) { clickPrefab = (Transform) EditorGUILayout.ObjectField ("Click marker:", clickPrefab, typeof (Transform), false); walkableClickRange = EditorGUILayout.Slider ("NavMesh search %:", walkableClickRange, 0f, 1f); doubleClickMovement = EditorGUILayout.Toggle ("Double-click to move?", doubleClickMovement); } if (movementMethod == MovementMethod.StraightToCursor) { dragRunThreshold = EditorGUILayout.FloatField ("Run threshold:", dragRunThreshold); singleTapStraight = EditorGUILayout.ToggleLeft ("Single-clicking also moves player?", singleTapStraight); if (singleTapStraight) { singleTapStraightPathfind = EditorGUILayout.ToggleLeft ("Pathfind when single-clicking?", singleTapStraightPathfind); } } if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen) { dragAffects = (DragAffects) EditorGUILayout.EnumPopup ("Touch-drag affects:", dragAffects); } if ((movementMethod == MovementMethod.Direct || movementMethod == MovementMethod.FirstPerson) && inputMethod != InputMethod.TouchScreen) { jumpSpeed = EditorGUILayout.Slider ("Jump speed:", jumpSpeed, 1f, 10f); } destinationAccuracy = EditorGUILayout.Slider ("Destination accuracy:", destinationAccuracy, 0f, 1f); if (destinationAccuracy == 1f && movementMethod != MovementMethod.StraightToCursor) { experimentalAccuracy = EditorGUILayout.ToggleLeft ("Attempt to be super-accurate? (Experimental)", experimentalAccuracy); } if (inputMethod == InputMethod.TouchScreen) { EditorGUILayout.Space (); EditorGUILayout.LabelField ("Touch Screen settings", EditorStyles.boldLabel); if (movementMethod != MovementMethod.FirstPerson) { offsetTouchCursor = EditorGUILayout.Toggle ("Drag cursor with touch?", offsetTouchCursor); } doubleTapHotspots = EditorGUILayout.Toggle ("Double-tap Hotspots?", doubleTapHotspots); } EditorGUILayout.Space (); EditorGUILayout.LabelField ("Camera settings", EditorStyles.boldLabel); cameraPerspective_int = (int) cameraPerspective; cameraPerspective_int = EditorGUILayout.Popup ("Camera perspective:", cameraPerspective_int, cameraPerspective_list); cameraPerspective = (CameraPerspective) cameraPerspective_int; if (movementMethod == MovementMethod.FirstPerson) { cameraPerspective = CameraPerspective.ThreeD; } if (cameraPerspective == CameraPerspective.TwoD) { movingTurning = (MovingTurning) EditorGUILayout.EnumPopup ("Moving and turning:", movingTurning); if (movingTurning == MovingTurning.TopDown || movingTurning == MovingTurning.Unity2D) { verticalReductionFactor = EditorGUILayout.Slider ("Vertical movement factor:", verticalReductionFactor, 0.1f, 1f); } } forceAspectRatio = EditorGUILayout.Toggle ("Force aspect ratio?", forceAspectRatio); if (forceAspectRatio) { wantedAspectRatio = EditorGUILayout.FloatField ("Aspect ratio:", wantedAspectRatio); #if UNITY_IPHONE landscapeModeOnly = EditorGUILayout.Toggle ("Landscape-mode only?", landscapeModeOnly); #endif } EditorGUILayout.Space (); EditorGUILayout.LabelField ("Hotpot settings", EditorStyles.boldLabel); hotspotDetection = (HotspotDetection) EditorGUILayout.EnumPopup ("Hotspot detection method:", hotspotDetection); if (hotspotDetection == HotspotDetection.PlayerVicinity && (movementMethod == MovementMethod.Direct || IsInFirstPerson ())) { hotspotsInVicinity = (HotspotsInVicinity) EditorGUILayout.EnumPopup ("Hotspots in vicinity:", hotspotsInVicinity); } else if (hotspotDetection == HotspotDetection.MouseOver) { scaleHighlightWithMouseProximity = EditorGUILayout.ToggleLeft ("Highlight Hotspots based on cursor proximity?", scaleHighlightWithMouseProximity); if (scaleHighlightWithMouseProximity) { highlightProximityFactor = EditorGUILayout.FloatField ("Cursor proximity factor:", highlightProximityFactor); } } if (cameraPerspective != CameraPerspective.TwoD) { playerFacesHotspots = EditorGUILayout.ToggleLeft ("Player turns head to active Hotspot?", playerFacesHotspots); } hotspotIconDisplay = (HotspotIconDisplay) EditorGUILayout.EnumPopup ("Display Hotspot icon:", hotspotIconDisplay); if (hotspotIconDisplay != HotspotIconDisplay.Never) { if (cameraPerspective != CameraPerspective.TwoD) { occludeIcons = EditorGUILayout.ToggleLeft ("Don't show behind Colliders?", occludeIcons); } hotspotIcon = (HotspotIcon) EditorGUILayout.EnumPopup ("Hotspot icon type:", hotspotIcon); if (hotspotIcon == HotspotIcon.Texture) { hotspotIconTexture = (Texture2D) EditorGUILayout.ObjectField ("Hotspot icon texture:", hotspotIconTexture, typeof (Texture2D), false); } hotspotIconSize = EditorGUILayout.FloatField ("Hotspot icon size:", hotspotIconSize); if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot && hotspotIconDisplay != HotspotIconDisplay.OnlyWhenFlashing) { hideIconUnderInteractionMenu = EditorGUILayout.ToggleLeft ("Hide when Interaction Menus are visible?", hideIconUnderInteractionMenu); } } #if UNITY_5 EditorGUILayout.Space (); EditorGUILayout.LabelField ("Audio settings", EditorStyles.boldLabel); volumeControl = (VolumeControl) EditorGUILayout.EnumPopup ("Volume controlled by:", volumeControl); if (volumeControl == VolumeControl.AudioMixerGroups) { musicMixerGroup = (AudioMixerGroup) EditorGUILayout.ObjectField ("Music mixer:", musicMixerGroup, typeof (AudioMixerGroup), false); sfxMixerGroup = (AudioMixerGroup) EditorGUILayout.ObjectField ("SFX mixer:", sfxMixerGroup, typeof (AudioMixerGroup), false); speechMixerGroup = (AudioMixerGroup) EditorGUILayout.ObjectField ("Speech mixer:", speechMixerGroup, typeof (AudioMixerGroup), false); musicAttentuationParameter = EditorGUILayout.TextField ("Music atten. parameter:", musicAttentuationParameter); sfxAttentuationParameter = EditorGUILayout.TextField ("SFX atten. parameter:", sfxAttentuationParameter); speechAttentuationParameter = EditorGUILayout.TextField ("Speech atten. parameter:", speechAttentuationParameter); } #endif EditorGUILayout.Space (); EditorGUILayout.LabelField ("Raycast settings", EditorStyles.boldLabel); navMeshRaycastLength = EditorGUILayout.FloatField ("NavMesh ray length:", navMeshRaycastLength); hotspotRaycastLength = EditorGUILayout.FloatField ("Hotspot ray length:", hotspotRaycastLength); moveableRaycastLength = EditorGUILayout.FloatField ("Moveable ray length:", moveableRaycastLength); EditorGUILayout.Space (); EditorGUILayout.LabelField ("Layer names", EditorStyles.boldLabel); hotspotLayer = EditorGUILayout.TextField ("Hotspot:", hotspotLayer); navMeshLayer = EditorGUILayout.TextField ("Nav mesh:", navMeshLayer); if (cameraPerspective == CameraPerspective.TwoPointFiveD) { backgroundImageLayer = EditorGUILayout.TextField ("Background image:", backgroundImageLayer); } deactivatedLayer = EditorGUILayout.TextField ("Deactivated:", deactivatedLayer); EditorGUILayout.Space (); EditorGUILayout.LabelField ("Loading scene", EditorStyles.boldLabel); useLoadingScreen = EditorGUILayout.Toggle ("Use loading screen?", useLoadingScreen); if (useLoadingScreen) { loadingSceneIs = (ChooseSceneBy) EditorGUILayout.EnumPopup ("Choose loading scene by:", loadingSceneIs); if (loadingSceneIs == ChooseSceneBy.Name) { loadingSceneName = EditorGUILayout.TextField ("Loading scene name:", loadingSceneName); } else { loadingScene = EditorGUILayout.IntField ("Loading screen scene:", loadingScene); } } EditorGUILayout.Space (); EditorGUILayout.LabelField ("Options data", EditorStyles.boldLabel); optionsData = Options.LoadPrefsFromID (0, false, true); if (optionsData == null) { Debug.Log ("Saved new prefs"); Options.SaveDefaultPrefs (optionsData); } defaultSpeechVolume = optionsData.speechVolume = EditorGUILayout.Slider ("Speech volume:", optionsData.speechVolume, 0f, 1f); defaultMusicVolume = optionsData.musicVolume = EditorGUILayout.Slider ("Music volume:", optionsData.musicVolume, 0f, 1f); defaultSfxVolume = optionsData.sfxVolume = EditorGUILayout.Slider ("SFX volume:", optionsData.sfxVolume, 0f, 1f); defaultShowSubtitles = optionsData.showSubtitles = EditorGUILayout.Toggle ("Show subtitles?", optionsData.showSubtitles); defaultLanguage = optionsData.language = EditorGUILayout.IntField ("Language:", optionsData.language); Options.SaveDefaultPrefs (optionsData); if (GUILayout.Button ("Reset options data")) { optionsData = new OptionsData (); optionsData.language = 0; optionsData.speechVolume = 1f; optionsData.musicVolume = 0.6f; optionsData.sfxVolume = 0.9f; optionsData.showSubtitles = false; Options.SavePrefsToID (0, optionsData, true); } EditorGUILayout.Space (); EditorGUILayout.LabelField ("Debug settings", EditorStyles.boldLabel); showActiveActionLists = EditorGUILayout.ToggleLeft ("List active ActionLists in Game window?", showActiveActionLists); showHierarchyIcons = EditorGUILayout.ToggleLeft ("Show icons in Hierarchy window?", showHierarchyIcons); if (GUI.changed) { EditorUtility.SetDirty (this); } }
static public void PlaySound(AudioClip clip, Vector3 pos, AudioMixerGroup group, float volume, bool isImportant){ if(audioManager==null) Init(); int ID=GetUnusedAudioObject(); if(ID == -1) return; audioObject[ID].inUse=true; audioObject[ID].thisT.position=pos; audioObject [ID].isImportant = isImportant; audioObject[ID].source.clip=clip; audioObject[ID].source.outputAudioMixerGroup = group; audioObject[ID].source.volume = volume; audioObject[ID].source.Play(); float duration=audioObject[ID].source.clip.length; audioManager.StartCoroutine(audioManager.ClearAudioObject(ID, duration)); }
public AudioSource PlayOnce(AudioClip clip, Vector3 position, Transform parent, AudioSourceConfiguration config, UnityEngine.Audio.AudioMixerGroup defaultGroup = null, float delay = 0) { if (clip == null) { Debug.LogError("Cannot play sound clip, because it is null"); return(null); } var go = CreateNewSource(clip, parent, config, defaultGroup); go.transform.position = position; var source = go.GetComponent <AudioSource>(); DontDestroyOnLoad(gameObject); source.PlayDelayed(delay); UnscaledDelayedDestroy.Apply(go, delay + clip.length / config.MinPitch + 0.01f); return(source); }
// Start is called before the first frame update void Start() { pitchBendGroup = Resources.Load <UnityEngine.Audio.AudioMixerGroup>("MusicLabMixer"); m_MyAudioSource = GetComponent <AudioSource>(); m_MyAudioSource.outputAudioMixerGroup = pitchBendGroup; }
public AudioSource PlayOnce(AudioClip clip, Vector3 position, AudioSourceConfiguration config, UnityEngine.Audio.AudioMixerGroup defaultGroup = null, float delay = 0) { return(PlayOnce(clip, position, transform, config, defaultGroup, delay)); }
public bool Play(AudioAsset audioAsset , bool loop = false , AudioMixerGroup audioMixerGroup = null) { if (IsPlaying) { return false; } if (audioAsset.AudioClip == null) { Debug.LogError("[AudioChannel] " + audioAsset + " has no AudioClip." , audioAsset); return false; } audioSource.clip = audioAsset.AudioClip; audioSource.outputAudioMixerGroup = audioMixerGroup ?? audioAsset.AudioMixerGroup; Volume = audioAsset.Volume; Pitch = audioAsset.Pitch; PanStereo = audioAsset.StereoPan; SpatialBlend = audioAsset.SpatialBlend; ReverbZoneMix = audioAsset.ReverbZoneMix; Loop = loop; AudioAsset = audioAsset; audioSource.Play(); return true; }
public AudioSource PlayOnce(AudioClip clip, float volume = 1, UnityEngine.Audio.AudioMixerGroup defaultGroup = null, float delay = 0) { return(PlayOnce(clip, transform.position, new AudioSourceConfiguration(volume), defaultGroup, delay)); }
public void RouteGroupToUnityMixerGroup(string sType, AudioMixerGroup mixerGroup) { var aGroup = GrabGroup(sType); if (aGroup == null) { return; } // ReSharper disable once TooWideLocalVariableScope SoundGroupVariation aVar; var sources = AudioSourcesBySoundType[sType].Sources; // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < sources.Count; i++) { aVar = sources[i].Variation; aVar.VarAudio.outputAudioMixerGroup = mixerGroup; } }
public virtual AudioSource PlaySomeClip(Vector3 pos, UnityEngine.Audio.AudioMixerGroup defaultGroup = null, float addedDelay = 0) { return(PlayClip(RandomId, pos, defaultGroup, addedDelay + _delay)); }