31 lines
679 B
C#
31 lines
679 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class backsound : MonoBehaviour
|
|
{
|
|
private static backsound instance;
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
GetComponent<AudioSource>().Play();
|
|
gameObject.name = "backsound on";
|
|
PlayerPrefs.SetFloat("volume", 1);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
GetComponent<AudioSource>().volume = PlayerPrefs.GetFloat("volume");
|
|
}
|
|
}
|