static control instance;
public static control Instance
{
get
{
if (instance == null)
{
instance = FindObjectOfType();
if (instance == null)
{
GameObject container = new GameObject();
container.name = "control";
instance = container.AddComponent();
}
DontDestroyOnLoad(instance);
}
return instance;
}
}
C#单例写法
最新推荐文章于 2022-07-04 14:08:02 发布