Exemplo n.º 1
0
    /// <returns>The standard source volume</returns>
    static private float Internal_PlayMusic(AudioPlayable playable, bool looping, float volumeMultiplier = 1)
    {
        if (!CheckResources_Instance() || !CheckResources_MusicSource())
        {
            return(0);
        }

        AudioSource source = GetAndIncrementMusicSource();

        source.volume = 1;

        if (looping)
        {
            playable.PlayLoopedOn(source, 1);
        }
        else
        {
            playable.PlayOn(source);
        }

        float stdVolume = source.volume;

        source.volume *= volumeMultiplier;
        return(stdVolume);
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        AudioPlayable playable = target as AudioPlayable;

        EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);

        GUILayoutOption largeHeight = GUILayout.Height(18 * 2 + 3);

        GUILayout.BeginHorizontal(largeHeight);

        GUI.enabled = _previewer.isPlaying;
        if (GUILayout.Button("Stop", largeHeight))
        {
            _previewer.Stop();
        }
        GUI.enabled = true;

        GUILayout.BeginVertical();
        if (GUILayout.Button("Preview"))
        {
            playable.PlayOnAndIgnoreCooldown(_previewer);
        }
        if (GUILayout.Button("Preview looped"))
        {
            if (_previewer.isPlaying)
            {
                _previewer.Stop();
            }
            playable.PlayLoopedOn(_previewer);
        }
        GUILayout.EndVertical();

        GUILayout.EndHorizontal();
        EditorGUI.EndDisabledGroup();
    }