fix: Cleanup after PR #3935

This commit is contained in:
MrGadget 2024-10-29 10:46:43 -04:00
parent af133e6110
commit f61524863e
6 changed files with 13 additions and 26 deletions

View File

@ -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() {}
/// <summary>The name of the current network scene.</summary>

View File

@ -196,8 +196,13 @@ public virtual void ServerLateUpdate() {}
/// <summary>Shut down the transport, both as client and server</summary>
public abstract void Shutdown();
/// <summary>Called by Unity when quitting. Inheriting Transports should call base for proper Shutdown.</summary>
// 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()
{

View File

@ -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();
}
}
}

View File

@ -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.
}

View File

@ -68,14 +68,6 @@ public class #SCRIPTNAME# : NetworkManager
base.ConfigureHeadlessFrameRate();
}
/// <summary>
/// called when quitting the application by closing the window / pressing stop in the editor
/// </summary>
public override void OnApplicationQuit()
{
base.OnApplicationQuit();
}
#endregion
#region Scene Management

View File

@ -15,8 +15,6 @@ public class #SCRIPTNAME# : NetworkManager
public event Action OnStartAction;
public event Action OnDestroyAction;
public event Action OnApplicationQuitAction;
public event Action<string> ServerChangeSceneAction;
public event Action<string> OnServerChangeSceneAction;
public event Action<string> OnServerSceneChangedAction;
@ -117,15 +115,6 @@ public class #SCRIPTNAME# : NetworkManager
base.ConfigureHeadlessFrameRate();
}
/// <summary>
/// called when quitting the application by closing the window / pressing stop in the editor
/// </summary>
public override void OnApplicationQuit()
{
OnApplicationQuitAction?.Invoke();
base.OnApplicationQuit();
}
#endregion
#region Scene Management