//private #endregion #region MonoBehaviour Methods private void Awake() { // Check if singleton has a reference if (SM_Instance != null) { // check if the reference is assigned to another gameObject if (SM_Instance != this) { // if true, destroy this gameObject Destroy(this); } // if reference is assigned to this object else if (SM_Instance == this) { // return out of function return; } } // if the reference isn't assigned else if (SM_Instance == null) { // set the reference to this gameObject SM_Instance = this; } TryGetComponent(out bgAudio); }
private void Start() { bgSound = BackgroundSoundManager.SM_Instance; scoreSystem = ScoreSystem.SS_Instance; particles = ParticleManager.PA_Instance; projectiles = ProjectileManager.PM_Instance; obstacles = FindObjectOfType <ObstacleManager>(); player = FindObjectOfType <PlayerController>(); }