|
|
|
|
|
|
public sealed class VolumeManager |
|
|
|
{ |
|
|
|
//>>> System.Lazy<T> is broken in Unity (legacy runtime) so we'll have to do it ourselves :|
|
|
|
|
static volatile VolumeManager s_Instance; |
|
|
|
static object s_LockObj = new UnityObject(); |
|
|
|
static readonly VolumeManager s_Instance = new VolumeManager(); |
|
|
|
public static VolumeManager instance { get { return s_Instance; } } |
|
|
|
public static VolumeManager instance |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
// Double-lock checking
|
|
|
|
if (s_Instance == null) |
|
|
|
{ |
|
|
|
lock (s_LockObj) // Lock on a separate object to avoid deadlocks
|
|
|
|
{ |
|
|
|
if (s_Instance == null) |
|
|
|
s_Instance = new VolumeManager(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return s_Instance; |
|
|
|
} |
|
|
|
} |
|
|
|
// Explicit static constructor to tell the C# compiler not to mark type as beforefieldinit
|
|
|
|
static VolumeManager() { } |
|
|
|
//<<<
|
|
|
|
|
|
|
|
// Internal stack
|
|
|
|