Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Writing Singletons, Help

$
0
0
I have 2 Singleton example scripts (A and B)

Is there any difference in the two?
Is one way better than the other, perfomance or otherwise?

Please explain

Singleton example A

Code (CSharp):
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class gameManager : MonoBehaviour
  5. {
  6.  
  7.     public int score;
  8.  
  9.     private static gameManager mySingleton;
  10.  
  11.     public gameManager Instance
  12.     {
  13.         get
  14.         {
  15.         return mySingleton;
  16.         }
  17.     }
  18.  
  19.     protected void Awake ()...
Writing Singletons, Help

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>