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#单例写法
最新推荐文章于 2025-07-08 23:00:46 发布
