summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/Utils/Singleton.cs
blob: d7aad49aea689645016daa7205f447249dc2b75b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Singleton<T> where T : class, new()
{
	private static T _instance;
	private static readonly object syslock = new object();

	public static T Instance
	{
		get
		{
			if (_instance == null)
			{
				lock (syslock)
				{
					if (_instance == null)
					{
						_instance = new T();
					}
				}
			}
			return _instance;

		}
	}
}