Question by
adrianfrancisco · Apr 11 at 05:10 PM ·
music
Again - AudioMixer works in editor but doesn't work in Android Device
So I found a question with the same problem as me, but sadly it wasn't answered. Anyone can help please?
Basically the sliders that modify the Music and the AudioFX work when I play in the editor in my computer, but not when building for android. I create the exposed parameters in the Audio Mixers that control the volume etc. As I said, it works when I hit play button, but not at all in my phone. This is the code:
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class VolumeSliders : MonoBehaviour
{
public AudioMixer mixer;
[SerializeField] private string audioMixerParameterName;//I create a PlayerPrefs float with the same Key
private Slider slider;
private void Awake()
{
slider = GetComponent<Slider>();
}
private void Start()
{
slider.value = PlayerPrefs.GetFloat(audioMixerParameterName, 1f);
}
public void SetVolume(Slider slider)
{
mixer.SetFloat(audioMixerParameterName, Mathf.Log10(slider.value) * 20);
PlayerPrefs.SetFloat(audioMixerParameterName, slider.value);
PlayerPrefs.Save();
}
}
Thank you!
Comment