Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
Transfering data between multiple scenes

I am new to C# and Unity and I tried to implement a volume slider. I can now adjust the volume, but the volume resets every time I try to load a new scene.

Could someone tell me how to transfer the volume to other scenes? I am using Unity 2018.3.14f1 and the code I am using for the volume is:

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

public class SetVolume : MonoBehaviour
{
    public AudioMixer mixer;

    public void SetLevel(float sliderValue)
    {
        mixer.SetFloat("MusicVol", Mathf.Log10(sliderValue) * 20);
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Save It in PlayerPrefs, Then load it on Start or anywhere you need it.

public class SetVolume : MonoBehaviour
{
    public AudioMixer mixer;
     
    
    void Start()
    {
        SetLevel(PlayerPrefs.GetFloat("MusicVol"));
    }

    public void SetLevel(float sliderValue)
    {
        PlayerPrefs.SetFloat("MusicVol", sliderValue);
        mixer.SetFloat("MusicVol", Mathf.Log10(sliderValue) * 20);
    }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda