From f61524863e445c28a9032a95f9fec4b13bfdd0e0 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:46:43 -0400 Subject: [PATCH] fix: Cleanup after PR #3935 --- Assets/Mirror/Core/NetworkManager.cs | 2 +- Assets/Mirror/Core/Transport.cs | 9 +++++++-- .../Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs | 4 +++- .../Mirror/Transports/Threaded/ThreadedTransport.cs | 5 ++--- ...0-Mirror__Network Manager-NewNetworkManager.cs.txt | 8 -------- ...r With Actions-NewNetworkManagerWithActions.cs.txt | 11 ----------- 6 files changed, 13 insertions(+), 26 deletions(-) diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 9a886fd98..b0445ac34 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -779,7 +779,7 @@ public virtual void OnDestroy() // don't use this anymore. // fixes: https://github.com/MirrorNetworking/Mirror/issues/2802 // DEPRECATED 2024-10-29 - [Obsolete("Override OnDestroy instead of OnApplicationQuit. Fixes: https://github.com/MirrorNetworking/Mirror/issues/2802")] + [Obsolete("Override OnDestroy instead of OnApplicationQuit.")] public virtual void OnApplicationQuit() {} /// The name of the current network scene. diff --git a/Assets/Mirror/Core/Transport.cs b/Assets/Mirror/Core/Transport.cs index ae9b37a86..485c1235a 100644 --- a/Assets/Mirror/Core/Transport.cs +++ b/Assets/Mirror/Core/Transport.cs @@ -196,8 +196,13 @@ public virtual void ServerLateUpdate() {} /// Shut down the transport, both as client and server public abstract void Shutdown(); - /// Called by Unity when quitting. Inheriting Transports should call base for proper Shutdown. - // use OnDestroy instead of OnApplicationQuit: + // [Obsolete] in case someone is inheriting it. + // don't use this anymore. + // fixes: https://github.com/MirrorNetworking/Mirror/issues/2802 + // DEPRECATED 2024-10-29 + [Obsolete("Override OnDestroy instead of OnApplicationQuit.")] + public virtual void OnApplicationQuit() {} + // fixes: https://github.com/MirrorNetworking/Mirror/issues/2802 public virtual void OnDestroy() { diff --git a/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs b/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs index 74945e1f6..9a911ee29 100644 --- a/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs +++ b/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs @@ -323,7 +323,7 @@ public void SetServerLobbyParams(LobbyCreateRequest request) _request = request; } - private void OnDestroy() + public override void OnDestroy() { // attempt to clean up lobbies, if active if (NetworkServer.active) @@ -340,6 +340,8 @@ private void OnDestroy() // sorry. this can go once the lobby service can timeout lobbies itself Thread.Sleep(300); } + + base.OnDestroy(); } } } diff --git a/Assets/Mirror/Transports/Threaded/ThreadedTransport.cs b/Assets/Mirror/Transports/Threaded/ThreadedTransport.cs index c1fea4992..59e90106e 100644 --- a/Assets/Mirror/Transports/Threaded/ThreadedTransport.cs +++ b/Assets/Mirror/Transports/Threaded/ThreadedTransport.cs @@ -197,11 +197,10 @@ void EnsureThread() Debug.Log($"ThreadedTransport: started worker thread!"); } - protected virtual void OnDestroy() + public override void OnDestroy() { // stop thread fully - Shutdown(); - + base.OnDestroy(); // TODO recycle writers. } diff --git a/Assets/ScriptTemplates/50-Mirror__Network Manager-NewNetworkManager.cs.txt b/Assets/ScriptTemplates/50-Mirror__Network Manager-NewNetworkManager.cs.txt index 15b0611df..61f8fe0e0 100644 --- a/Assets/ScriptTemplates/50-Mirror__Network Manager-NewNetworkManager.cs.txt +++ b/Assets/ScriptTemplates/50-Mirror__Network Manager-NewNetworkManager.cs.txt @@ -68,14 +68,6 @@ public class #SCRIPTNAME# : NetworkManager base.ConfigureHeadlessFrameRate(); } - /// - /// called when quitting the application by closing the window / pressing stop in the editor - /// - public override void OnApplicationQuit() - { - base.OnApplicationQuit(); - } - #endregion #region Scene Management diff --git a/Assets/ScriptTemplates/51-Mirror__Network Manager With Actions-NewNetworkManagerWithActions.cs.txt b/Assets/ScriptTemplates/51-Mirror__Network Manager With Actions-NewNetworkManagerWithActions.cs.txt index 887e76f97..9d9752b31 100644 --- a/Assets/ScriptTemplates/51-Mirror__Network Manager With Actions-NewNetworkManagerWithActions.cs.txt +++ b/Assets/ScriptTemplates/51-Mirror__Network Manager With Actions-NewNetworkManagerWithActions.cs.txt @@ -15,8 +15,6 @@ public class #SCRIPTNAME# : NetworkManager public event Action OnStartAction; public event Action OnDestroyAction; - public event Action OnApplicationQuitAction; - public event Action ServerChangeSceneAction; public event Action OnServerChangeSceneAction; public event Action OnServerSceneChangedAction; @@ -117,15 +115,6 @@ public class #SCRIPTNAME# : NetworkManager base.ConfigureHeadlessFrameRate(); } - /// - /// called when quitting the application by closing the window / pressing stop in the editor - /// - public override void OnApplicationQuit() - { - OnApplicationQuitAction?.Invoke(); - base.OnApplicationQuit(); - } - #endregion #region Scene Management