diff options
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 |