summaryrefslogtreecommitdiff
path: root/Singleton/Singleton.cs
blob: 4b5ae4701ff13309ce3e18952d2c5fe31e84b490 (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
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assets.Scripts.Tools.Singleton
{
    class Singleton<T> where T : class, new()
    {
        private static T _instance; 

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

        public static void Release()
        {
            if (_instance != null)
                _instance = null;
        }
    }
}