diff options
author | chai <chaifix@163.com> | 2020-10-14 12:44:29 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-10-14 12:44:29 +0800 |
commit | dcaad8044384bce4f4358522108bf9a2481ee4e0 (patch) | |
tree | fb6cf33d05c66356b0c5d533e266aaa341210a3e /Assets/Scripts/Utils/Singleton.cs | |
parent | 4056f06baea18d3c5ae23c4a022fc6ae6b135bb2 (diff) |
*physics
Diffstat (limited to 'Assets/Scripts/Utils/Singleton.cs')
-rw-r--r-- | Assets/Scripts/Utils/Singleton.cs | 20 |
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 |