• Как в Unity сделать синхронизацию музыки между сценами и регулировку все музыки через другую сцену?

    @vvvsklier Автор вопроса
    Код для регулировки P.s два кода не мои с ютуба

    [Header("Components")]
    [SerializeField] private AudioSource audio1;
    [SerializeField] private Slider slider1;
    [SerializeField] private Text text1; // создаем переменную текст что бы сохранять сколько сейчас звука текстом

    [Header("Keys")]
    [SerializeField] private string saveVolumeKey;

    [Header("Tags")]
    [SerializeField] private string sliderTag;
    [SerializeField] private string textVolumeTag;

    [Header("Parameters")]
    [SerializeField] private float volume;

    private void Awake()
    {
    if (PlayerPrefs.HasKey(this.saveVolumeKey))
    {
    this.volume = PlayerPrefs.GetFloat(this.saveVolumeKey);
    this.audio1.volume = this.volume;

    GameObject sliderObj = GameObject.FindWithTag(this.sliderTag);
    if (sliderObj != null)
    {
    this.slider1 = sliderObj.GetComponent();
    this.slider1.value = this.volume;
    }
    }
    else
    {
    this.volume = 0.5f;
    PlayerPrefs.SetFloat(this.saveVolumeKey, this.volume);
    this.audio1.volume = this.volume;
    }

    }

    private void LateUpdate()
    {
    GameObject sliderObj = GameObject.FindWithTag(this.sliderTag);
    if (sliderObj != null)
    {
    this.slider1 = sliderObj.GetComponent();
    this.volume = slider1.value;

    if (this.audio1.volume != this.volume)
    {
    PlayerPrefs.SetFloat (this.saveVolumeKey,this.volume);
    }

    GameObject textObj = GameObject.FindWithTag(this.textVolumeTag);
    if (textObj != null)
    {
    this.text1 = textObj.GetComponent();

    this.text1.text = Mathf.Round (f:this.volume*100) + "%"; //функция умножаем на 100 и делим на процент что бы текстом высчитывать ровные значения и отсекать дробные числа
    }

    this.audio1.volume = this.volume;

    }

    }
    Написано