예제 #1
0
    private void Awake()
    {
        if ((_instance != null) && (_instance.GetInstanceID() != this.GetInstanceID()))
        {
            Debug.LogWarning($"Second GameCoordinator instance detected. Original: '{_instance.gameObject.name}', new: '{this.gameObject.name}'", this);

            _level  = _instance._level;
            _health = _instance._health;
            _ammo   = _instance._ammo;

            Destroy(_instance.gameObject);
            _instance = null;
        }

        DontDestroyOnLoad(this.gameObject);

        _instance = this;
    }