Files
powerfun-unity/Assets/Scenes/Ride/Scripts/Singleton.cs
T

28 lines
627 B
C#
Raw Normal View History

2021-05-11 18:21:32 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scenes.Ride.Scripts
{
public abstract class Singleton<T> where T : class, new()
{
private static T instance = null;
private static readonly object locker = new object();
public static T Instance
{
get
{
lock (locker)
{
if (instance == null)
instance = new T();
return instance;
}
}
}
}
}