Unity小白文——单例的定义
2024-09-05 09:00:09
当类继承与MonoBehaviour时
public class TestSingle : MonoBehaviour
{
public static TestSingle Instance;
void Awake()
{
Instance = this ;
}
}
当类不继承与MonoBehaviour时
public class TestSingle :
{
public static TestSingle instance;
public static TestSingle Instance
{
get
{
if(instance == null)
instance = new TestSingle();
return instance;
}
}
}
最新文章
- 关于linux中文乱码的问题。
- Redis介绍以及安装(Linux)
- NodeJS介绍
- Android_listview_scrollListener
- iOS动画技术笔记
- nginx 目录密码保护的设置方法
- Java学习笔记之I/O
- @synchronized(self)
- Java 中文编码分析
- .NET Core装饰模式和.NET Core的Stream
- VMware小记
- Failed to load ApplicationContext ,Error creating bean with name 'adminUserService': Injection of autowired dependencies failed;
- win 10 升级远程连接服务器 要求的函数不受支持
- java学习——异常处理
- 为什么redis使用单线程还能这么快?
- Vue的新启之笔
- 【python】基础入门
- Delphi按名字调用方法高级解决方案
- Java-URLEncoder.encode 什么时候才是必须的
- 动态规划:POJ 3616 Milking Time