From c35533e31efe30121a7c61a725fdaaba47714296 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Tue, 9 May 2023 10:17:45 +0800 Subject: *misc --- marching/Assets/Scripts/Common/Singleton.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 marching/Assets/Scripts/Common/Singleton.cs (limited to 'marching/Assets/Scripts/Common/Singleton.cs') 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 where T : class, new() +{ + private static T _instance; + + public static T Instance + { + get + { + if (_instance == null) + _instance = Activator.CreateInstance(); + return _instance; + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0