Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!