MakeSingleton









How do I use Make Singleton
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Scores.cs Copy
15  void Awake () {
16   GameStartedFirstTime ();
17   MakeSingleton ();
18  }
File name: Scores.cs Copy
25  void MakeSingleton () {
26   if (instance != null) {
27    Destroy (gameObject);
28   } else {
29    instance = this;
30    DontDestroyOnLoad (gameObject);
31   }
32  }
File name: MusicController.cs Copy
11  void Start () {
12         MakeSingleton();
13         audioSource = GetComponent();
14  }
File name: MusicController.cs Copy
16     void MakeSingleton()
17     {
18         if (instance != null)
19         {
20             Destroy(gameObject);
21         }
22         else
23         {
24             instance = this;
25             DontDestroyOnLoad(gameObject);
26         }
27     }
File name: Score.cs Copy
11     void Start () {
12         MakeSingleton();
13         GameStartedFirstTime();
14  }
File name: Score.cs Copy
16     void MakeSingleton() {
17         if (instance != null)
18         {
19             Destroy(gameObject);
20         }
21         else
22         {
23             instance = this;
24             DontDestroyOnLoad(gameObject);
25         }
26     }
File name: Scores.cs Copy
12  void Awake () {
13   GameStartedFirstTime ();
14   MakeSingleton ();
15  }
File name: Scores.cs Copy
22  void MakeSingleton () {
23   if (instance != null) {
24    Destroy (gameObject);
25   } else {
26    instance = this;
27    DontDestroyOnLoad (gameObject);
28   }
29  }

MakeSingleton 122 lượt xem

Gõ tìm kiếm nhanh...