- Home /
Question by
KebabasZ · Nov 20, 2017 at 01:47 PM ·
scripting problemaudiosliderscenes
I need help with my audio slider
Hello, i've been stuck trying figuring out how to save my "Slider" value when i'm changing scenes. I have a script where it doesn't destroy my background music through all of the scenes. So when I use my slider the music changes, but when I go to another scene and then come back the value resets and when I try to change it the music's volume doesn't change. So basiclly when I change the value and then go to another scene it resets can anyone help me? Here's my don't destroy on load script.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class BGSoundScript : MonoBehaviour {
// Use this for initialization
void Start()
{
}
//Play Global
private static BGSoundScript instance = null;
public static BGSoundScript Instance
{
get { return instance; }
}
void Awake()
{
if (instance != null && instance != this)
{
Destroy(this.gameObject);
return;
}
else
{
instance = this;
}
DontDestroyOnLoad(this.gameObject);
}
//Play Gobal End
// Update is called once per frame
void Update()
{
}
}
Comment