33 lines
766 B
C#
33 lines
766 B
C#
using UnityEngine;
|
|
|
|
|
|
namespace VRBeats
|
|
{
|
|
public class VolumeSingleton : MonoBehaviour
|
|
{
|
|
private static VolumeSingleton Instance;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
VolumeSingleton[] instancesArray = FindObjectsByType<VolumeSingleton>(FindObjectsSortMode.None);
|
|
|
|
foreach (var volumeSingleton in instancesArray)
|
|
{
|
|
if (volumeSingleton != Instance)
|
|
{
|
|
Destroy(volumeSingleton.gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|