コード例 #1
0
ファイル: backgroundmusic.cs プロジェクト: 407351129/charlie
 // Start is called before the first frame update
 void Awake()
 {
     if (Backgroundmusic == null)
     {
         Backgroundmusic = this;
         DontDestroyOnLoad(Backgroundmusic);
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #2
0
 void MakeSingletone()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Destroy(gameObject);
     }
 }