using System.Collections; using System.Collections.Generic; using UnityEngine; /******************************************************************************* *Create By CG *Function 普通类单例模式 *******************************************************************************/ namespace CG.Framework { public class ClassSingleton where T : ClassSingleton { private volatile static T _instance = null; protected ClassSingleton() { } private static readonly object sysObj = new object(); public static T Instance { get {//懒汉式 if (_instance == null) { lock (sysObj) { if (_instance == null) { _instance = System.Activator.CreateInstance(typeof(T), true) as T; } } } return _instance; } } } }