📅  最后修改于: 2022-03-11 14:48:45.749000             🧑  作者: Mango
public class SomeClass : MonoBehaviour {
private static SomeClass _instance;
public static SomeClass Instance { get { return _instance; } }
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(this.gameObject);
} else {
_instance = this;
DontDestroyOnLoad(gameObject);
}
}
}