Exemplo n.º 1
0
 public static void StopImmediate(AudioSource audioSource, float delay = 0)
 {
     AudioPlayerOld.StopImmediate(audioSource, delay);
 }
Exemplo n.º 2
0
 public static void Stop(List <AudioSource> audioSources, float delay = 0)
 {
     AudioPlayerOld.Stop(audioSources, delay);
 }
Exemplo n.º 3
0
 public static void StopAll(float delay = 0)
 {
     AudioPlayerOld.StopAll(delay);
     Instance.coroutineHolder.RemoveAllCoroutines();
 }
Exemplo n.º 4
0
 public static List <AudioSource> PlayRepeating(float repeatRate, string instrumentName, int[] midiNotes, float[] velocities, GameObject sourceObject = null, float delay = 0, AudioPlayerOld.SyncMode syncMode = AudioPlayerOld.SyncMode.None)
 {
     return(AudioPlayerOld.PlayRepeating(repeatRate, new Note(instrumentName, midiNotes, velocities), sourceObject, delay, syncMode));
 }
Exemplo n.º 5
0
    void OnGUI()
    {
//		GUILayout.BeginHorizontal();
//		GUILayout.Space(5);
//		AudioPlayer.Buses["Piano"] = GUILayout.VerticalSlider(AudioPlayer.Buses["Piano"], 100, 0);
//		GUILayout.Space(5);
//		GUILayout.BeginVertical();

        // Plays a sound at position (0, 0, 0); returns the AudioSource
        if (GUILayout.Button(" Play Simple "))
        {
            sound = AudioPlayerOld.Play("Piano_C1");
        }

        // Plays a sound that follows the specified gameObject
        if (GUILayout.Button(" Play Spatialized "))
        {
            sound = AudioPlayerOld.Play("Piano_C1", gameObject);
        }

        // Plays multiple sounds at once; returns the audioSources as List<AudioSource>
        if (GUILayout.Button(" Play Multiple "))
        {
            sounds = AudioPlayerOld.Play(new string[3] {
                "Piano_C3", "Piano_C4", "Piano_C5"
            });
        }

        // Plays a container defined in the AudioPlayer inspector
        // Note that the returned List might be modified at any time by the AudioPlayer; make a copy
        // of it if you need to iterate through.
        if (GUILayout.Button(" Play Container "))
        {
            sounds = AudioPlayerOld.Containers["Mysterious"].Play();
        }

        // Plays any of the above repeatedly
        if (GUILayout.Button(" Play Repeatedly "))
        {
            sounds = AudioPlayerOld.PlayRepeating(0.125F, AudioPlayerOld.Containers["Mysterious"], gameObject, 0, AudioPlayerOld.SyncMode.Measure);
        }

        // Pauses a sound
        if (GUILayout.Button(" Pause Last Sound "))
        {
            AudioPlayerOld.Pause(sound);
            AudioPlayerOld.Pause(sounds);
        }

        // Pauses all sounds
        if (GUILayout.Button(" Pause All "))
        {
            AudioPlayerOld.PauseAll();
        }

        // Resumes a sound
        if (GUILayout.Button(" Resume Last Sound "))
        {
            AudioPlayerOld.Resume(sound);
            AudioPlayerOld.Resume(sounds);
        }

        // Resumes all sounds
        if (GUILayout.Button(" Resume All "))
        {
            AudioPlayerOld.ResumeAll();
        }

        // Sets the volume of a sound
        if (GUILayout.Button(" Set Last Sounds Volume 25% "))
        {
            AudioPlayerOld.SetVolume(sound, 25);
            AudioPlayerOld.SetVolume(sounds, 25);
        }

        // Sets the volume of a sound with fade
        if (GUILayout.Button(" Set Last Sounds Volume 100% Over 2 Seconds "))
        {
            AudioPlayerOld.SetVolume(sound, 100, 2);
            AudioPlayerOld.SetVolume(sounds, 100, 2);
        }

        // Sets the master volume
        if (GUILayout.Button(" Set Master Volume 100% "))
        {
            AudioPlayerOld.SetMasterVolume(100);
        }

        // Sets the master volume with fade
        if (GUILayout.Button(" Set Master Volume 25% Over 2 Seconds "))
        {
            AudioPlayerOld.SetMasterVolume(25, 2);
        }

        // Stops a sound with fade out
        if (GUILayout.Button(" Stop Last Sound With Fade Out "))
        {
            AudioPlayerOld.Stop(sound);
            AudioPlayerOld.Stop(sounds);
        }

        // Stops all sounds without fade out
        if (GUILayout.Button(" Stop All Without Fade Out "))
        {
            AudioPlayerOld.StopAllImmediate();
        }

//		GUILayout.EndVertical();
//		GUILayout.EndHorizontal();
    }
Exemplo n.º 6
0
    void ShowRTPCs()
    {
        if (audioPlayer.rTPCs == null)
        {
            return;
        }

        SerializedProperty rTPCsProperty = serializedObject.FindProperty("rTPCs");

        if (AddElementFoldOut(rTPCsProperty, "RTPCs".ToGUIContent()))
        {
            audioPlayer.rTPCs[audioPlayer.rTPCs.Length - 1]      = new AudioPlayerOld.RTPC();
            audioPlayer.rTPCs[audioPlayer.rTPCs.Length - 1].name = AudioPlayerOld.GetUniqueName(audioPlayer.rTPCs, "default");
        }

        if (rTPCsProperty.isExpanded)
        {
            EditorGUI.indentLevel += 1;

            for (int i = 0; i < audioPlayer.rTPCs.Length; i++)
            {
                AudioPlayerOld.RTPC rtpc         = audioPlayer.rTPCs[i];
                SerializedProperty  rtpcProperty = rTPCsProperty.GetArrayElementAtIndex(i);

                EditorGUILayout.BeginHorizontal();
                rtpc.showing = EditorGUILayout.Foldout(rtpc.showing, rtpc.name);
                GUILayout.Space(30);
                if (!rtpc.showing)
                {
                    rtpc.defaultValue = EditorGUILayout.Slider(rtpc.defaultValue, rtpc.minValue, rtpc.maxValue);
                }
                GUILayout.Space(10);
                DeleteElementButtonWithArrows(rTPCsProperty, i);
                if (deleteBreak)
                {
                    break;
                }
                EditorGUILayout.EndHorizontal();

                if (rtpc.showing)
                {
                    EditorGUI.indentLevel += 1;

                    EditorGUI.BeginChangeCheck();
                    EditorGUI.BeginDisabledGroup(Application.isPlaying);
                    rtpc.name = EditorGUILayout.TextField(rtpc.name);
                    EditorGUI.EndDisabledGroup();
                    rtpc.defaultValue = EditorGUILayout.Slider("Value", rtpc.defaultValue, rtpc.minValue, rtpc.maxValue);
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(rtpcProperty.FindPropertyRelative("minValue"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        rtpcProperty.FindPropertyRelative("maxValue").floatValue = Mathf.Max(rtpcProperty.FindPropertyRelative("maxValue").floatValue, rtpcProperty.FindPropertyRelative("minValue").floatValue);
                    }
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(rtpcProperty.FindPropertyRelative("maxValue"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        rtpcProperty.FindPropertyRelative("minValue").floatValue = Mathf.Clamp(rtpcProperty.FindPropertyRelative("minValue").floatValue, 0, rtpcProperty.FindPropertyRelative("maxValue").floatValue);
                    }
                    rtpcProperty.FindPropertyRelative("minValue").floatValue = Mathf.Max(rtpcProperty.FindPropertyRelative("minValue").floatValue, 0);
                    rtpcProperty.FindPropertyRelative("maxValue").floatValue = Mathf.Max(rtpcProperty.FindPropertyRelative("maxValue").floatValue, 0);
                    if (EditorGUI.EndChangeCheck())
                    {
                        rtpcProperty.FindPropertyRelative("changed").boolValue = true;
                    }
                    Separator();

                    EditorGUI.indentLevel -= 1;
                }
            }
            EditorGUI.indentLevel -= 1;
        }
    }
Exemplo n.º 7
0
    void ShowContainers()
    {
        if (audioPlayer.containers == null)
        {
            return;
        }

        SerializedProperty containersProperty = serializedObject.FindProperty("containers");

        if (AddElementFoldOut(containersProperty, "Containers".ToGUIContent()))
        {
            audioPlayer.containers[audioPlayer.containers.Length - 1]               = new AudioPlayerOld.Container();
            audioPlayer.containers[audioPlayer.containers.Length - 1].name          = AudioPlayerOld.GetUniqueName(audioPlayer.containers, "default");
            audioPlayer.containers[audioPlayer.containers.Length - 1].subContainers = new List <AudioPlayerOld.SubContainer>();
        }

        if (containersProperty.isExpanded)
        {
            EditorGUI.indentLevel += 1;

            for (int i = 0; i < audioPlayer.containers.Length; i++)
            {
                AudioPlayerOld.Container container = audioPlayer.containers[i];
                currentContainer = container;
                SerializedProperty containerProperty = containersProperty.GetArrayElementAtIndex(i);

                if (DeleteElementFoldOutWithArrows(containersProperty, i, container.name.ToGUIContent()))
                {
                    break;
                }

                if (container.showing)
                {
                    EditorGUI.indentLevel += 1;

                    EditorGUI.BeginDisabledGroup(Application.isPlaying);
                    container.name = EditorGUILayout.TextField(container.name);
                    EditorGUI.EndDisabledGroup();
                    container.containerType = (AudioPlayerOld.Container.ContainerTypes)EditorGUILayout.EnumPopup(container.containerType);
                    ShowSources(container, containerProperty);

                    EditorGUI.indentLevel -= 1;
                }
            }
            EditorGUI.indentLevel -= 1;
        }
    }
Exemplo n.º 8
0
    void ShowBuses()
    {
        if (audioPlayer.buses == null)
        {
            return;
        }

        SerializedProperty busesProperty = serializedObject.FindProperty("buses");

        if (AddElementFoldOut(busesProperty, "Buses".ToGUIContent()))
        {
            audioPlayer.buses[audioPlayer.buses.Length - 1]      = new AudioPlayerOld.AudioBus();
            audioPlayer.buses[audioPlayer.buses.Length - 1].name = AudioPlayerOld.GetUniqueName(audioPlayer.buses, "default");
        }

        if (busesProperty.isExpanded)
        {
            EditorGUI.indentLevel += 1;

            for (int i = 0; i < audioPlayer.buses.Length; i++)
            {
                AudioPlayerOld.AudioBus bus         = audioPlayer.buses[i];
                SerializedProperty      busProperty = busesProperty.GetArrayElementAtIndex(i);

                EditorGUILayout.BeginHorizontal();
                bus.showing = EditorGUILayout.Foldout(bus.showing, bus.name);
                GUILayout.Space(30);
                if (!bus.showing)
                {
                    bus.volume = EditorGUILayout.Slider(bus.volume, 0, 100);
                }
                GUILayout.Space(10);
                DeleteElementButtonWithArrows(busesProperty, i);
                if (deleteBreak)
                {
                    break;
                }
                EditorGUILayout.EndHorizontal();

                if (bus.showing)
                {
                    EditorGUI.indentLevel += 1;

                    EditorGUI.BeginDisabledGroup(Application.isPlaying);
                    bus.name = EditorGUILayout.TextField(bus.name);
                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.PropertyField(busProperty.FindPropertyRelative("volume"));
                    Separator();

                    EditorGUI.indentLevel -= 1;
                }

                if (bus.pVolume != bus.volume)
                {
                    bus.changed = true;
                    bus.pVolume = bus.volume;
                }
            }
            EditorGUI.indentLevel -= 1;
        }
    }