Ejemplo n.º 1
0
    private void Awake()
    {
        //Check if we already got an instance, if so delete the object
        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        //Create a new instance of the instance
        _instance = this;
    }
Ejemplo n.º 2
0
    private void OnDestroy()
    {
        //Make sure we clear the instance static variable to be able to recreate it later
        if (_instance == this)
        {
            _instance = null;
        }

        //Tidy up event references
        if (MainNetworkManager._instance != null)
        {
            MainNetworkManager._instance.ClientShutdown -= OnClientStopped;
            MainNetworkManager._instance.HostShutdown   -= OnClientStopped;
        }
    }