u3d单例类
来源:互联网 发布:软件权限管理 编辑:程序博客网 时间:2024/06/05 16:42
public class Singleton<T> : MonoBehaviour where T : Singleton<T> { private static T instance; public static T Instance { get { return instance; } } /// <summary> /// Returns whether the instance has been initialized or not. /// </summary> public static bool IsInitialized { get { return instance != null; } } /// <summary> /// Base awake method that sets the singleton's unique instance. /// </summary> protected virtual void Awake() { if (instance != null) { Debug.LogErrorFormat("Trying to instantiate a second instance of singleton class {0}", GetType().Name); } else { instance = (T) this; } } protected virtual void OnDestroy() { if (instance == this) { instance = null; } } }
如何使用
public class xxx: Singleton<xxx>
0 0
- u3d单例类
- u3d
- u3d
- u3d
- u3d
- u3d
- u3d
- u3d
- u3d
- u3d 地形 U3d terrain
- U3D 相关
- U3D背包
- U3d学习
- U3D记事本
- U3d协程
- U3D相关
- U3D 开发
- u3d 1
- raster导入postgres Windows命令
- SQL Server 事务复制分发到订阅同步慢
- poj 2142 拓展欧几里得 砝码
- 《FreeSWITCH: VoIP实战》:FreeSWITCH 初步
- 函数式编程 高级集合类和收集器
- u3d单例类
- Java多线程(一)
- HDU5978 To begin or not to begin(概率+规律)
- APP安全报告第十四期:十款热门旅行APP,竟有九款APP的安全评分不及格!
- 【HDU1520】Anniversary Party-树形DP求树的最大权值独立集
- 最长上升子序列,LIS<DP+二分>
- Unity 3D
- 第十天
- GD32F130FXP6学习笔记十一:KEIL MDK输出map文件分析