summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Utils/Singleton.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-14 12:44:29 +0800
committerchai <chaifix@163.com>2020-10-14 12:44:29 +0800
commitdcaad8044384bce4f4358522108bf9a2481ee4e0 (patch)
treefb6cf33d05c66356b0c5d533e266aaa341210a3e /Assets/Scripts/Utils/Singleton.cs
parent4056f06baea18d3c5ae23c4a022fc6ae6b135bb2 (diff)
*physics
Diffstat (limited to 'Assets/Scripts/Utils/Singleton.cs')
-rw-r--r--Assets/Scripts/Utils/Singleton.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/Assets/Scripts/Utils/Singleton.cs b/Assets/Scripts/Utils/Singleton.cs
new file mode 100644
index 00000000..bdec31d3
--- /dev/null
+++ b/Assets/Scripts/Utils/Singleton.cs
@@ -0,0 +1,20 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+using System;
+
+public class Singleton<T> where T : class, new()
+{
+ private static T _instance;
+
+ public static T Instance
+ {
+ get
+ {
+ if (_instance == null)
+ _instance = Activator.CreateInstance<T>();
+ return _instance;
+ }
+ }
+} \ No newline at end of file