diff options
Diffstat (limited to 'marching/Assets/Scripts/Common')
-rw-r--r-- | marching/Assets/Scripts/Common/Singleton.cs | 16 | ||||
-rw-r--r-- | marching/Assets/Scripts/Common/Singleton.cs.meta | 11 |
2 files changed, 27 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 diff --git a/marching/Assets/Scripts/Common/Singleton.cs.meta b/marching/Assets/Scripts/Common/Singleton.cs.meta new file mode 100644 index 0000000..9a9cdf7 --- /dev/null +++ b/marching/Assets/Scripts/Common/Singleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02534dc90b1e47743969d14d9386660d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |