summaryrefslogtreecommitdiff
path: root/Singleton/Singleton.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Singleton/Singleton.cs')
-rw-r--r--Singleton/Singleton.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Singleton/Singleton.cs b/Singleton/Singleton.cs
new file mode 100644
index 0000000..4b5ae47
--- /dev/null
+++ b/Singleton/Singleton.cs
@@ -0,0 +1,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;
+ }
+ }
+}