﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;

public class SetMixerFloatPrefs : MonoBehaviour
{
    [System.Serializable]
    public class Preference
    {
        public string name;
        public float defaultValue = 1;
        public AnimationCurve curve;
    }

    public AudioMixer mixer;
    public Preference[] preferences;

    private void Start()
    {
        foreach(var p in preferences)
        {
            float value = PlayerPrefs.GetFloat(p.name, p.defaultValue);
            if (p.curve != null && p.curve.keys.Length >= 2)
                value = p.curve.Evaluate(value);

            mixer.SetFloat(p.name, value);
        }    
    }
}
