Example #1
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More than one BuildingSlotManager in scene !"); return;
     }
     instance = this;
 }
Example #2
0
    private void Awake()
    {
        if (_instance == null)
        {
            //if not, set instance to this
            _instance = this;
        }
        //If instance already exists and it's not this:
        else if (_instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        // DontDestroyOnLoad(gameObject); // cant do because its not a root obj in scene
    }
Example #3
0
    private void SetUpObjects()
    {
        if (_playerStats == null)
        {
            _playerStats = GameObject.FindObjectOfType <PlayerStats>();
        }
        if (_playerMovement == null)
        {
            _playerMovement = GameObject.FindObjectOfType <PlayerMovement>();
        }
        if (_BuildingSlots == null)
        {
            _BuildingSlots = GameObject.FindObjectOfType <BuildingSlotManager>();
        }

        setUp = true;
    }