From 340ac9c806b58c2ab54007d98bed397eb7a16065 Mon Sep 17 00:00:00 2001 From: baletiballo <75846481+baletiballo@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:31:12 +0100 Subject: [PATCH] Make sure the local MMT server gets killed if the game unexpectedly closes in a level Doesn't work in the launch menu, because globalObject doesn't exist there yet, but still better than nothing --- Assets/Scripts/GlobalBehaviour.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Assets/Scripts/GlobalBehaviour.cs b/Assets/Scripts/GlobalBehaviour.cs index 243cf100..8fb3b5ca 100644 --- a/Assets/Scripts/GlobalBehaviour.cs +++ b/Assets/Scripts/GlobalBehaviour.cs @@ -277,4 +277,19 @@ IEnumerator _GetContextfromServer() yield break; } } + + /// <summary> + /// Make sure the local MMT server gets killed if the game closes. + /// </summary> + private void OnApplicationQuit() + { + StreamingAssetLoader.NetworkJSON_Save(); + if (CommunicationEvents.process_mmt_frameIT_server != null) + { + if (!CommunicationEvents.process_mmt_frameIT_server.HasExited) + { + CommunicationEvents.process_mmt_frameIT_server.Kill(); + } + } + } } -- GitLab