void OnQuit() { if (_use_connection) { switch (_connection_mode) { case "ros": Debug.Log("Closing Connection with ROS"); if (_robot_connection != null) { ((Networking.ROSConnection)_robot_connection).close_connection(); _robot_connection = null; } break; case "thalamus": break; default: break; } } if (_instance != null) { _instance = null; } }
// Use this for initialization void Start() { if (_instance == null) { DontDestroyOnLoad(gameObject); _instance = this; // Initialize IPs and ports (Android vs Linux/Windows/Mac vs Editor) if (!Application.isEditor) { string os = SystemInfo.operatingSystem; if (os.ToLower().Contains("android")) { initialize_android(); } else if (os.ToLower().Contains("windows") || os.ToLower().Contains("mac") || os.ToLower().Contains("linux")) { initialize_standalone(); } } _rand_generator = new System.Random(); if (_use_connection && (_robot_connection == null)) { _ask_start = DateTime.MinValue; switch (_play_mode) { case "regular": if (_connection_mode.Contains("ros")) { //TODO } else if (_connection_mode.Contains("thalamus")) { //TODO } break; case "help": if (_connection_mode.Contains("ros")) { _robot_connection = new Networking.RosBridge.AskHelpROS(_connection_ip, _connection_port); //((Networking.RosBridge.AskHelpROS)_robot_connection).advertize(_ros_pub_topic, "std_msgs/String"); ((Networking.RosBridge.AskHelpROS)_robot_connection).subscribe(_ros_sub_topic, "std_msgs/String"); _game_begin = DateTime.Now; } else if (_connection_mode.Contains("thalamus")) { //TODO } break; default: break; } } } else if (_instance != this) { gameObject.SetActive(false); return; } }