公共类游戏管理器: MonoBehaviour {
公共静态Gamemanager实例;SerializeField私有空唤醒(){
if(instance == null) // if instance is not initilized then instance is equal to class
instance =this;}
}//classs
发布于 2021-06-30 23:59:28
基本上,我们希望确保静态(!)" instance“变量将始终保存对同一Gamemanager实例的引用,即使出于某种原因,创建了多个Gamemanager实例。如上所述,这也被称为“单例模式”。
https://stackoverflow.com/questions/68196946
复制相似问题