——个人学习笔记
tips:想看详细,可去本人学习之地:https://blog.csdn.net/ycl295644/article/details/49487361
public class Manager
{
static Manager instance;
public static Manager Instance {
get {
if (instance == null) {
instance = new Manager ();
//或者instance=this;
}
return instance;
}
}
}
- 简单的单例 (二)
public class Manager
{
static Manager Intance ;
void Awake()
{
//保持只有一个
if (Intance == null)
{
Intance = this;
}
else if (Intance != this)
{
Destroy(this.gameObject);
}
}
}