How to leave a game?

Options
This sounds like it should be trivial... :)

I have a 2 player server/client game. I've made a small behaviour so if Escape is pressed it should disconnect from the game.
using UnityEngine;

public class GameQuitHandler : MonoBehaviour {

  void OnGUI() {
    Event e = Event.current;
    if(e.isKey) {
      Debug.Log("Detected Key Code: " + e.keyCode);
      if(e.keyCode == KeyCode.Escape) {
        Debug.Log("ESCAPE");
        BoltNetwork.LoadScene("Main Menu");
      }
    }
  }
}
It seems this is not enough, though. I end up back on the Main Menu scene, but I seem to have all the instantiated objects from my game.

I've tried searching but cant see any obvious suggestions. Any thoughts?

Comments

  • njt1982
    Options
    Hmm my mistake, I didn't realise there was a difference between a discussion and a question post type!
  • stanchion
    Options
    BoltNetwork.Shutdown()
  • njt1982
    Options
    image

    Hmm I dont seem to have that method on the class. Is it an instance method?
  • njt1982
    Options
    Ahhh wait...
    BoltLauncher.Shutdown()
    
    ?
  • stanchion
    Options
    Yes sorry
  • njt1982
    Options
    That Shutdown thing definitely made a huge difference. I can now quit to the main menu and none of the game stuff spawns up + I can restart/join other games without Bolt complaining that its already running.