diff options
author | chai <215380520@qq.com> | 2023-05-09 10:17:45 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-05-09 10:17:45 +0800 |
commit | c35533e31efe30121a7c61a725fdaaba47714296 (patch) | |
tree | b25bc22f00911f376c741b89b0591d2d48565e79 /marching/Assets/Scripts/Common/Singleton.cs | |
parent | d2a574ba76c56c340d8ac0ad841344664bc2cc59 (diff) |
*misc
Diffstat (limited to 'marching/Assets/Scripts/Common/Singleton.cs')
-rw-r--r-- | marching/Assets/Scripts/Common/Singleton.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/marching/Assets/Scripts/Common/Singleton.cs b/marching/Assets/Scripts/Common/Singleton.cs new file mode 100644 index 0000000..bb382e2 --- /dev/null +++ b/marching/Assets/Scripts/Common/Singleton.cs @@ -0,0 +1,16 @@ +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 |